Я хочу проанализировать файл, чтобы извлечь данные; < /p>
Вот пример журнала:

UPDATE:
I have Used the following Code to extract Test Results, I would like have suggestions on this code:
Код: Выделить всё
public int FilterLogFile(File LogFile) {
int TestCount = 0;
try {
String Line = "";
BufferedReader br = new BufferedReader(new FileReader(LogFile));
while ((Line = br.readLine()) != null) {
Scanner scanner = new Scanner(Line);
String line = scanner.findInLine(".*(Test Count:)\\s+\\d+\\D+\\s+.*(Passed:)\\s+\\d+\\D+\\s+.*(Failed:)\\s+\\d+");
if (line != null) {
System.out.println("Detected Line: " + line);
TestCount = ExtractData(Line);
break;
} else {
continue;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return TestCount;
}
private int ExtractData(String strLine) {
int Count = 0;
try {
String[] Data = strLine.split(",");
for (String str : Data) {
if (str.contains("Test Count:")) {
int value = Integer.parseInt(str.replaceAll("[^0-9]", ""));
Count = value;
System.out.println(value);
break;
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return Count;
}
Подробнее здесь: https://stackoverflow.com/questions/448 ... r-log-file