Carriage Return\Line feed in Java
Posted
by Manu
on Stack Overflow
See other posts from Stack Overflow
or by Manu
Published on 2010-05-14T08:25:02Z
Indexed on
2010/05/14
8:34 UTC
Read the original article
Hit count: 276
java
Guys,
i have created text file in unix enviroment using java code.
For writing the text file i am using java.io.FileWriter
and BufferedWriter
.
and for newline after each row i am using bw.newLine()
method.
(where bw
is object of BufferedWriter
)
and sending that text file by attaching in mail from unix environment itself (automated that using unix commands).
My issue is, after i download the text file from mail in windows system, if i opened that text file the data's are not properly aligned. newline() character is not working i think so.
I want same text file alignment as it is in unix environment, if i opened the text file in windows environment also.
How to resolve the problem.Please help ASAP. Thanks for your help in advance.
pasting my java code here for your reference..(running java code in 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();
}
© Stack Overflow or respective owner