Java 8 write to file using BufferedWriter
BufferedWriter is used to write text to a character or byte stream. Before printing the characters, it stores the characters in buffer and print in bunches.
Without buffering, each invocation of a print() method would cause characters to be converted into bytes that would then be written immediately to the file, which can be very inefficient.
Example in Java 8 to write content:
Write to file using Files.write()
Using Files.write() method is also pretty much clean code.
Above both methods are good for almost all use cases which need to write the file in Java 8.