Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

How to write newline character to file using bytes along with content

807600May 31 2007 — edited May 31 2007
Hi All,

I need to write headers into the file using byte[]. I am creating the strings of header which will form the different rows in the file. I am new to java and would like to know how to embed new line character so that when the byte[] is written to file headers come in different rows.
like
hrd1:abcd
hdr2:1234
when i embed \n and \r in string and do getBytes() and write it to file, some boxes are written in the file and everything comes into single line.
Please advice me the correct way .

Thanks in advance.
Cheers!!
Puneet
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 28 2007
Added on May 31 2007
4 comments
952 views