I created a text file in a Unix environment using Java code.
To write a text file, I use java.io.FileWriter and BufferedWriter . And for a new line after each line, I use the bw.newLine() method (where bw is the BufferedWriter object).
And I send this text file, attaching it by mail from the Unix environment itself (automated using Unix commands).
My problem is that after downloading a text file from mail on Windows, if I opened this text file, the data was not correctly aligned. The newline() symbol does not work, I think so.
I want the same text file alignment as in Unix if I opened the text file in Windows.
How to solve a problem?
The Java code below is for your reference (runs on a Unix environment):
File f = new File(strFileGenLoc); BufferedWriter bw = new BufferedWriter(new FileWriter(f, false)); rs = stmt.executeQuery("select * from jpdata"); while ( rs.next() ) { bw.write(rs.getString(1)==null? "":rs.getString(1)); bw.newLine(); }
java carriage-return eol line-endings linefeed
Manu May 14, '10 at 8:25 2010-05-14 08:25
source share