在没有给出路径的情况下,在java中创建新文件的位置?

在java中,

File f; f = new File("myfile.txt"); if (!f.exists()) { f.createNewFile(); } 

当执行上面的代码时,默认情况下分配了哪条路径,而没有给出特定的路径?

当前目录,您可以通过调用获得:

 new File('.').getCanonicalPath(); 

当前目录。

当前目录。 显然, System.getProperty("user.dir")可以为您提供此function。