All I am trying is to implement a simple text-editor. I will keep this simple for now.
I have a text-area and string variable to hold the text and a file to write the contents of the text-area. Intuitively, I think there is a better way (better readability/agile code) to do the same below and this should work for notepad  :
 FileWriter out = new FileWriter("filename.txt");
 String sh = jTextArea1.getText();
 for (int i=0; i<sh.length(); i++)
 {
     if (sh.charAt(i) ==  '\n')
          out.write("\r\n");
     else
         out.write(sh.charAt(i));
  }
  out.close();
 
     
     
     
    