我試圖做一個小程序,它會從文件中讀取輸入並打印出來,如果他們匹配特定的格式是:掃描文件驗證
Team Name : Another Team name : Score : Score
這裏是我做了什麼等等到目前爲止,如果你能在正確的方向指向我,我會很感激
import java.util.Scanner;
import java.io.File;
import java.io.FileNotFoundException;
public class Generator {
public static void main(String[] args) throws FileNotFoundException{
String file;
Scanner fileScan;
fileScan = new Scanner (new File("document.txt"));
int count = 0;
while (fileScan.hasNextLine()){
file = fileScan.nextLine();
System.out.println(file);
count++;
}
System.out.println(count+ " number of lines successfully validated");
}
}
我想程序驗證格式是否有效,如果不是不打印線,但保持數所以我可以在最後輸出多少行未被正確驗證。
謝謝。
什麼是你期望 – kirti 2014-10-31 14:45:11