I want to save text from a JTextArea to a file, the code below works perfectly fine but the only thing is that the line breaks aren't converted. This means no matter how many lines I have in the JTextArea, they are all displayed in one line in the text file.
BufferedWriter writer = new BufferedWriter(new FileWriter(file));
writer.append(textArea.getText());
writer.close();
What should I do to fix this problem?