PrintWriter默认位置

Jaw*_*wap 1 java macos printwriter

我正在尝试写入文件.代码运行没有错误,但我无法在任何地方找到该文件.不在执行路径,桌面,主文件夹,根文件夹中.

当然我可以指定绝对路径,但我想弄清楚相对路径是什么,因为我看过这样的例子.

try {
    PrintWriter out = new PrintWriter ("example.txt");
    out.print("test");
    out.flush();
    out.close();
} catch (FileNotFoundException e) {
    e.printStackTrace();
}
Run Code Online (Sandbox Code Playgroud)

Rei*_*eus 5

该文件存在于当前应用程序路径中,如下所示 new File("example.txt").getAbsolutePath()