我收到“找不到文件!”无论我做什么。
FileInputStream fin;
try {
fin = new FileInputStream("foo.txt");
String str = IOUtils.toString(fin);
System.out.println(str);
} catch (FileNotFoundException f) {
System.out.println("File not found!");
}
最佳答案
您正在工作的目录中有 foo.txt 吗?
如果您使用命令窗口并且位于 C:\位置,那么您的代码预计 foo.txt 会出现在那里。
如果您的 foo.txt 存在于其他路径中,请在代码中使用完整路径。
关于java - FileInputStream 读取的文件存储在哪里?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33244000/