javawindowslinuxnewlineprintln

Java println: Windows vs Linux


I have a java program that writes a file to a remote machine file system using the jcifs library -samba stuff; SmbFile=>SmbFileOutputStream=>PrintStream and the I use the common println(String). Everything worked fine till I moved my application to a linux machine and now the printed file on my remote windows machine looks weird.

I believe the problem is how the two OSs handle the CR, LF that are inserted by the println() function. My 'jar' is executed once a day and it's triggered by the 'crontab' through a 'sh' launch file.

Thank you


Solution

  • Try playing around with the system property "line.separator". You can read this for reference.