- path 基本带了file 对象
- Files 提供了便捷的 io 操作 比原来的io 香太多了
- newBufferedWriter 其中这种 new开头 返回流的方法,我真的是看了半天才看懂,英文不好泪目public enum StandardOpenOption
- 其中 OpenOption… 是一个枚举类型 来返回流的类型
Enum StandardOpenOption
java.lang.Object
public static void main(String[] args) throws IOException {
Path path = Paths.get("目标文件");
Stream<String> gbk = Files.lines(path, Charset.forName("UTF-8"));
List<String> collect = gbk.collect(Collectors.toList());
String enm = "";
for (String s : collect) {
enm += s;
}
Files.newByteChannel(path, StandardOpenOption.WRITE).write(ByteBuffer.wrap(enm.getBytes()));
}