我有一个包含
等数据的文件FileName : 105_IZMIR-REGRESSION-DEV-MAP-MANAGMENT.html 14 scenarios 2 failed, 12 passed Failed scenario: IZMIR-1623.001 IZMIR-1623.006 FileName : 105_IZMIR-REGRESSION-DEV-VOICE-MANAGMENT.html
我编写了以下代码来获取单个文件中两个文件名之间的数据。我想在两个不同的字符串中输入数据的前两行(即14 scenarios
2 failed, 12 passed
),并将下面的3合在一起,以便稍后我可以将其插入到SQL中。如何实现这一目标?
代码:
package com.Script;
import java.io.FileInputStream;
import java.io.InputStreamReader;
import java.util.Scanner;
import javax.sound.sampled.Line;
public class Script_Read {
public static void main(String[] args) throws Exception {
try {
Scanner scanner = new Scanner(new FileInputStream("E:\\Result.txt"));
boolean tokenFound = false;
while (scanner.hasNextLine()) {
String line= scanner.nextLine();
if (line.endsWith("IZMIR-REGRESSION-DEV-VOICE-MANAGMENT.html"))
{
tokenFound = true;
} else if (line.endsWith("IZMIR-REGRESSION-DEV-GUIDANCE-enter code hereVIEW.html")) {
tokenFound = false;
}
if ((tokenFound) && (!line.endsWith("IZMIR-REGRESSION-DEV-VOICE-MANAGMENT.html"))) {
System.out.println(lines);
}
}
} catch (Exception e) {
System.out.println("File not found.");
}
}
}