0
how to write to a file?
2 ответов
+ 1
Reading text files into memory and writing strings into a text file in Java 8 is finally a simple task. No messing around with readers and writers. The method Files.readAllLines reads all lines of a given file into a list of strings. You can simply modify this list and write the lines into another file via Files.write:
List<String> lines = Files.readAllLines(Paths.get("res/mrk.js"));
lines.add("print('foobar');");
Files.write(Paths.get("res/mrk-modified.js"), lines);