我嘗試讀取文本文件並查找給定的參數,如果這是真的,它應該爲我提供整個列表條目。搜索列表並返回整個條目
多數民衆贊成在文件中輸入:100 0100045391 0400053454 0502028765251 ABH ZL1 1560112 2010年7月6日100 0100045394 0400055024 0502028766382 ABH ZL1 1601944 21.06.2010
但此刻我只可以檢查此參數列表或者不是或者給定的參數本身。
import groovy.util.CharsetToolkit;
//Pathname
def pathname = "C:/mySupport-eclipse/trackandtrace.txt"
//Error State
int errorCode = 0
def bsknr = "0100045553"
//Define new file
def file = new File(pathname)
if(!file.exists())
{
errorCode = 1
}
else
{
//Read lines, seperated by tab
file.splitEachLine ('\t') {
list -> list
println list.findAll {it.contains(bsknr)}
}
}
+1我總是忘了'filterLine' –
'filterLine'是我的網關藥物的Groovy ... –
謝謝你,那娃正是我正在尋找的東西 – CollinG