Hi all,

I am using RandomAccessFile, to create a log file. The log file gets created fine, when I open it in UNIX (I mean the display layout). However, when I open the file in Windows, in notepad, then I see instead of '\n' a little square. So all the lines are created side by side in one line.

My question is how can I prevent that from happening, when I open in Windows?

Is there a special technique I can use to be able to implement '\n', when I open my file in Windowws?

Appreciate your adivise.

Thanks and regards.

Recommended Answers

All 6 Replies

I use Notepad++ it is a highly functional text editor, available open source from sourceforge. There are alternatives liek textpad and ultraedit.

Your issue is that windows and linux/unix use a different newline sequence. Mac used to as well - perhaps it still does?

The only way to get around the problem is to output in the format that you use most frequently (windows or *nix) - or use a text viewer that is aware of other formats. Notepad isn't. But if you don't want to download something (or can't) then just open your file in wordpad.

why use a RandomAccessFile for it anyway, and not an established logging package?
There's a logging API built into the language by now, and several alternatives like Log4J as well that do an excellent job.

why use a RandomAccessFile for it anyway, and not an established logging package?
.

Can you elaborate alittle bit on logging package, please? where is this package located? and etc..

Thanks.

java.util.logging :)

java.util.logging :)

Thanks, I will look into it.

BTW, its not a problem with your program, its a problem with the text editor which are not intelligent enough to make out the newlines. You could of course try using the 'newline' property of the System class but again with an editor like Notepad, the results are not very promising.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.