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!

Weird characters appear after write to a file

807607Jan 3 2007 — edited Jan 5 2007
Here is my story:

I open a file using RandomAccessFile to replace some characters inside it. Let's say I have in the file string 4000, I replace it by string 400. It works fine.

Now if I replace this number by string 40000, when I check the text file, some weird characters like ^M appear everywhere at the end of lines.

What's the reason and how to solve it? I believe there is some invisible characters at the end of string 4000 that causes the problem.

Note that I use function writeBytes to write strings into the file.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 2 2007
Added on Jan 3 2007
39 comments
1,501 views