且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在java中的目录中创建文件?

更新时间:2023-11-29 19:07:52

***的方法是:

String path = "C:" + File.separator + "hello" + File.separator + "hi.txt";
// Use relative path for Unix systems
File f = new File(path);

f.getParentFile().mkdirs(); 
f.createNewFile();