I have an application where I want to write a string to the file as newline at EOF.
My program executes on Linux OS and the file that I want to to write resides in a windows shared folder.
Problem: I am able to add string to the file as a newline, when I run the program on windows OS using eclipse. But when deploy and run the app on Linux box, string gets added to the file but not as a newline.
Eg: Let’s say if I want to add a new string as ‘test user’ to the file, this is how it adds.
Hr usr
Hi usr
Jk usrtest user
I want it to be like
Hr usr
Hi usr
Jk usrt
test user
BufferedWriter bw = new BufferedWriter(new FileWriter(fileUrl, true));
bw.newLine();
//didn’t write newline when I deployed it to Linux box
bw.write();
//OR
bw.append(System.lineSeperator() + “mystring”);
//didn’t write newline when I deployed it to Linux box
//OR
bw.append(“\r\n” + “mystring”);
//didn’t write newline when I deployed it to Linux box
I am pretty sure code wise nothing is wrong, somewhere UNIX or Windows getting confused with the newline separation.
Any input would be greatly appreciated.
Thanks, Jeevan.