Possible Duplicate:
Java: How do I get a platform independent new line character?
I want to write enter into file with class RandomFileAccess
, but I can't do it properly.
What should I do ?
Like this code :
char enter = '\n' ;
outputfile.writeChar(enter);
I'm Using Windows.... Thanks for your help but it didn't work :(
public class MainClass {
public static void main(String[] args) {
String BeforEnter = "It's Before Enter...";
String Enter = System.getProperty("line.separator");
String AfterEnter = "It must be on next Line...";
File MyFile = new File("test.txt");
try {
RandomAccessFile TextFile = new RandomAccessFile(MyFile, "rw");
TextFile.writeChars(BeforEnter);
TextFile.writeChars(Enter);
TextFile.writeChars(AfterEnter);
TextFile.close();
I expected this Style of File :
It's Before Enter...
It must be on next Line...
But it gets like this : :(
I t ' s B e f o r e E n t e r . . . I t m u s t b e o n n e x t L i n e . . .