title: Why this simple program leads to different carriage return/line feed file when executed in Java and AIX?
body: <p>If I run this simple program on Windows 7 and then on AIX (Unix system) and compare the two generated files using a tool such as Winmerge or Compare It, it tells me that the Carriage Return and Line Feed are different but the content identical. </p>
  
  <ul>
  <li><p>Why is that? Isn't supposed to be the same if both use the same encoding "UTF-8" in this case? </p></li>
  <li><p>How can I make both files totally equal?</p></li>
  </ul>
  
  <p></p>
  
  <pre><code>public class WriteFile {
  
      public static void main(String[] args) throws IOException {
          write();
  
      }
  
      public static void write() throws IOException {
          File file = new File("/tmp/test.txt");
          file.delete();
          file.createNewFile();
          String str = "hello";
          FileOutputStream fileOs = new FileOutputStream(file);
          PrintWriter writer = new PrintWriter(new OutputStreamWriter(fileOs, "UTF-8"), true);
          writer.println(str);
          writer.close();
      }
  
  }
  </code></pre>