Files can be written bite- and line-wise using the Files
class
Path p2 = Paths.get("/home/testuser/File.txt");
List<String> lines = Arrays.asList(
new String[]{"First line", "Second line", "Third line"});
Files.write(p2, lines);
Files.write(Path path, byte[] bytes)
Existing files wile be overridden, non-existing files will be created.