Files

JDK7使用Files代替了File------------------------------------>NIO代替常规得IO

  创建目录

 Path parPath = null;
 parPath = Files.createDirectories(Paths.get(localFilePath));   localFilePath为文件存储地址

创建文件
 Path path = Files.createTempFile(parPath, null, null);
 BufferedWriter outputStream = Files.newBufferedWriter(path, StandardCharsets.UTF_8);

写入内容

outputStream.write("要写入得内容");
outputStream.newLine();//换行

outputStream.flush();//刷新缓存区

Files.delete(path);//删除原文件

 

posted @ 2017-11-22 14:34  C&R  阅读(292)  评论(0编辑  收藏  举报