So I'm using a BufferedWriter and would like to write some text to a text file.
try {
BufferedWriter b = new BufferedWriter(new FileWriter ("/home/usr/Desktop/logger/logs.txt"));
b.write("hello");
} catch (Exception e1) { e1.printStackTrace(); }
For some reason the text document is being created but nothing is being written to it, why is this?
You need to close
BufferedWriter
, or usetry-with-resource