Loading...
Logo
Processing Forum

raf.write() println()

in Programming Questions  •  2 years ago  
I'm merging some Java program with my own.
 
I have these lines:
    raf = new RandomAccessFile(ff, "rw");
    // Append to the end
    raf.seek(raf.length());
    raf.writeChars("abc");//writes 2-bytes Unicode char
    raf.write("ABC".getBytes());//writes 1-byte char
Now how can I write to a new line, using the equivalent of println()?
I tried raf.writeln(), raf.writeLine(), raf.writeChars("/n") and raf.writeChar("/n") but doesn't work.

Replies(2)

/n is just two chars. Not sure if you really used this or if you wrote it this way because the forum is ill behaved with backslash n...
I see neither writeln nor writeLine in RandomAccessFile. writeChar cannot work with a String. Reading the doc might be useful...
I would try the raf.write("\n".getBytes()); as it writes plain Ascii chars instead of UTF-16 chars like writeChars do.
So maybe I used the wrong backlash?
I tried it again but the output text file is still on one line.
I guess raf files don't really have lines.
Anyway I will find another way using Processing, cause this Java stuff is getting too involved for me.
SaveStrings() should do.