好吧,我搜索了这个网站和其他一些人寻找这个问题的答案并尝试了所有的建议。没有什么工作,它不断抛出File not found exception
。使用eclipse无法找到文件
File inFile = new File("PhoneRecords.txt");
String path = inFile.getAbsolutePath();
try {
System.setIn(new FileInputStream(path));
} catch (FileNotFoundException e) {
e.printStackTrace();
}
Scanner sc = new Scanner(System.in);
之后它尝试在下面的方法中使用扫描仪。
public static PhoneCall readNextPhoneCall(Scanner sc){
return new PhoneCall (sc.nextDouble(), sc.nextInt());
}
的文本文件是在我在我的工作同一个目录和我双确信,我在我的代码正确命名它。请帮忙。
使用Eclipse调试器。设置一个断点并遍历代码,以查看哪些行为无法满足您对发生的事情的假设。 – duffymo 2014-10-10 12:53:34
可能的[重复](http://stackoverflow.com/q/19871955/2587435) – 2014-10-10 12:55:12
将它保持在与source/bin目录相同的级别,然后尝试。 – TheLostMind 2014-10-10 12:56:24