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.
- Is there a way to fix the issue without touching the java code?
- Is there a way to write a java program to make it work on both kind of OSs (possibly all of them)?
Thank you
Try playing around with the system property “line.separator”. You can read this for reference.