This code writes the string to a file. It is important to close the writer, so this is done in a finally block.
public void writeLineToFile(String str) throws IOException {
File file = new File("file.txt");
BufferedWriter bw = null;
try {
bw = new BufferedWriter(ne...