【发布时间】:2014-12-01 11:24:24
【问题描述】:
方法返回FileNotFoundException:
String statSource = 'some path';
try {
File file = new File(statSource);
if (!file.exists())
{
System.out.println(file.getPath() + " doesn't exist!");
}
else
{
System.out.println("OK!");
}
// otevření CSV
csv = new CsvReader(statSource, ';', Charset.forName("windows-1250"));
}
起初我得到“好的!”消息,但在最后一行我得到FileNotFoundException。文件位于本地硬盘上。
你知道出了什么问题吗?
【问题讨论】:
-
无论文件是否存在,您的
CsvReader都会进行初始化。 -
statsource路径是目录还是文件?
-
FileNotFoundException是 JDK 最无用的例外,因为当文件存在但您无法读取/写入它时,您也会得到它。因此,发布完整的堆栈跟踪:只有相关的消息可能会给出提示。
标签: java netbeans-7 filenotfoundexception