-1
我不明白如何從下面的.txt
文件讀取數據。fileReader和掃描儀
static final String DATA_PATH = "DataFile.txt";
public static void main(String[] args) {
Scanner fileReader = null;
try {
fileReader = new Scanner(new File(DATA_PATH));
//Print out a trace of the program as it is running
System.out.println("Debug: Scanner is open "+fileReader);
} catch (FileNotFoundException e) {
// If the file is not there, an exception will be thrown and the program flow
// will directed here. An error message is displayed and the program stops.
System.out.println("The file "+DATA_PATH+" was not found!");
System.out.println("The program terminates now.");
System.exit(0);
}
真的嗎?你甚至保留練習號碼 – meda
你的冒險精神在哪裏? :)查看'Scanner'類(web || textbook)的文檔,即使最後輸入一段時間,比如'fileReader.',也應該打開IntelliSense並給出一些想法。 (當你剛剛啓動stackoverflow時,我不會'-1') –