public StormAnalysis(){
try {
fScanner = new Scanner(new File("tracks1949to2010_epa.txt"));
while(fScanner.hasNextLine()){
System.out.println(fScanner.nextLine());
}
} catch (FileNotFoundException e) {
System.out.println("File not found. Try placing the tracks1949to2010_epa.txt in the same folder as StormAnalysis.java");
e.printStackTrace();
}
}
以上是我的代码(我也有错误的图像:http: //folk.uio.no/arnabkd/test/images/error-code-task.jpg
如您所见,txt 文件与 StormAnalysis.java 文件位于同一文件夹中。此外,如果我将文件路径更改为“weather.dat”(作为另一个任务/问题给出),该代码将起作用。
任何想法将不胜感激!