Where will be create a new file in java, when path is not given?

后端 未结 3 1001
深忆病人
深忆病人 2021-01-06 21:54

In java,

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

when excute the above code,which path is assig

相关标签:
3条回答
  • 2021-01-06 22:24

    The current directory, which you can get by calling:

    new File('.').getCanonicalPath();
    
    0 讨论(0)
  • 2021-01-06 22:37

    The current directory.

    0 讨论(0)
  • 2021-01-06 22:48

    The current directory. Apparently System.getProperty("user.dir") can get this for you.

    0 讨论(0)
提交回复
热议问题