title: Writing multiline JTextArea content into file
body: <p>I have to write the content of textarea into a file with line breaks. I got the output like, it is written as one string in the file.</p>
  
  <pre><code>public void actionPerformed(ActionEvent ev) {
  
  text.setVisible(true);
  String str= text.getText();
  System.out.println(str);
  
  try {
      BufferedWriter fileOut = new BufferedWriter(new FileWriter("filename.txt")); 
  
  
      fileOut.write(str);
  
      fileOut.close();
  } catch (IOException ioe) {
      ioe.printStackTrace();
  }
  }
  </code></pre>
  
  <p>Example</p>
  
  <p>Output should be:</p>
  
  <pre><code>I
  am
  King.
  </code></pre>
  
  <p>but it is showing:</p>
  
  <pre><code>IamKing.
  </code></pre>
  
  <p>Please get me some suggestions</p>