Java 7 way to write a file

2019-03-06 15:32发布

I have managed to read a file by

Files.copy(Paths.get(file.toURI()), System.out);

How do I write a sequence of characters to a file? I see no effect from

Files.copy(new ByteArrayInputStream(content.getBytes()), Paths.get(file.getName()))

and it looks ugly.

标签: stream java-7
1条回答
放我归山
2楼-- · 2019-03-06 16:04

I have succeeded this way

Files.write(Paths.get(file.getName()), content.getBytes());
查看更多
登录 后发表回答