/**
* 从文件中载入测试集
*
* @throws IOException
*/
public static ArrayList<Tx> loadTestCases(String fileName) throws IOException {
System.out.println("================================ 1。 end load testSet ================================");
ArrayList<Tx> testSet = new ArrayList<>(); // 测试集
BufferedReader br = null;
try {
br = new BufferedReader(new FileReader(new File(fileName)));
String line = null;
while ((line = br.readLine()) != null) {
line = line.trim();
if (!line.isEmpty()) {
String[] info = line.split(" ");
Tx tx = new Tx(Integer.parseInt(info[1]), Integer.parseInt(info[2]));
testSet.add(tx);
}
}
}
finally {
if (br != null) {
br.close();
}
}
// 打印测试
for(int i = 0;i < testSet.size(); i ++){
System.out.println(testSet.get(i));
}
System.out.println("================================ 2。 end load testSet ================================");
return testSet;
}
公众号:微程序学堂