发布日期:2018-03-26
在Java如何中创建目录?+ 查看更多
在Java如何中创建目录?
+ 查看更多
发布日期:2018-02-23 18:00
分类:JAVA
浏览次数:113
我要如何创建目录/文件夹?
一旦我测试:
一旦我测试:
System.getProperty("user.home");
当且仅当新文件夹不存在时,我不得不创建一个目录(目录名“新文件夹”)。
回答:
File theDir = new File("new folder"); // if the directory does not exist, create it if (!theDir.exists()) { System.out.println("creating directory: " + theDir.getName()); boolean result = false; try{ theDir.mkdir(); result = true; } catch(SecurityException se){ //handle it } if(result) { System.out.println("DIR created"); } }