我正在试着写一个文件。代码运行时没有错误,但是我在任何地方都找不到该文件。不在执行路径、桌面、主文件夹、根文件夹中。
当然,我可以指定绝对路径,但我正在尝试弄清楚相对路径是相对于什么,因为我见过这样的示例。
try {
PrintWriter out = new PrintWriter ("example.txt");
out.print("test");
out.flush();
out.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
}发布于 2013-03-20 06:41:56
存在的文件位于new File("example.txt").getAbsolutePath()指示的当前应用程序路径中
发布于 2013-03-20 06:41:26
你检查过java.io.tmpdir了吗?它可能会默认到该位置。它是一个系统属性。
https://stackoverflow.com/questions/15511868
复制相似问题