java8 write file 写文件
2018-05-23 11:35 晨曦曙光 阅读(15905) 评论(0) 编辑 收藏 举报1.用BufferedWriter写入文件
//Get the file reference Path path = Paths.get("c:/output.txt"); //Use try-with-resource to get auto-closeable writer instance try (BufferedWriter writer = Files.newBufferedWriter(path)) { writer.write("Hello World !!"); }
2.用 Files.write()写入文件
String content = "Hello World !!"; Files.write(Paths.get("c:/output.txt"), content.getBytes());