本文实例汇总了Java文件操作.docx

本文实例汇总了Java文件操作。分享给大家供大家参考,具体如下: 1.创建文件夹 ? 1 2 3 4 5 6 7 8 9 10 11 //import java.io.*; File myFolderPath = new File(%%1); try { if (!myFolderPath.exists()) { myFolderPath.mkdir(); } } catch (Exception e) { System.out.println(新建目录操作出错); e.printStackTrace(); } 2.创建文件 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 //import java.io.*; File myFilePath = new File(%%1); try { if (!myFilePath.exists()) { myFilePath.createNewFile(); } FileWriter resultFile = new FileWriter(myFilePath); PrintWriter myFile = new PrintWriter(resultFile); myFile.println(%%2); resultFile.close(); } catch (Ex

文档评论(0)

1亿VIP精品文档

相关文档