我不明白如何从.txt
下面的文件中读取数据。
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);
}