How do I provide a file path in Mac OS X while creating a file in Java?

后端 未结 4 648
旧时难觅i
旧时难觅i 2021-02-04 04:28
File f = new File(\"C:\\\\Temp\\\\Example.txt\");
f.createNewFile();

On executing, a new file named \"Example.txt\" will be created in the Temp

4条回答
  •  春和景丽
    2021-02-04 05:12

    Forward slash "/" must be used to get the file path here. Use:

    File f = new File("/Users/pavankumar/Desktop/Testing/Java.txt");
    f.createNewFile();
    

提交回复
热议问题