Skip to Main Content

Java Programming

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!

writing to text file using randomaccessfile

807580Jan 20 2010 — edited Jan 20 2010
I am using RandomAccessFile to write String into text file

RandomAccessFile output = new RandomAccessFile("C:/FaultObject1.java", "rw");
byte[] stringAsBytes = line.getBytes("UTF-16");
output.write(stringAsBytes);

where line is String. It is not able to write spaces, like I have some lines which doesn't have text but just empty lines and I do want it
to put it the same way. Is there any way?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 17 2010
Added on Jan 20 2010
14 comments
1,443 views