-
writing to a file
I am randomly accessing a file and want to append text at the end of the file. I am trying following code.
Code:
File file = new File("C:\\myFile.txt");
RandomAccessFile raf = new RandomAccessFile(file, "rw");
raf.seek(file.length());
raf.write("MyMessage");
I get exception at following like:
Code:
raf.write("MyMessage");
saying:
Code:
The method write(int) in the type RandomAccessFile is not applicable for the arguments (String)
Any clues??
-
Look in the Methods Summary section of the RandomAccessFile class api.
There are three write methods none of which take a String argument. Methods that take a String argument are writeBytes(String s) and writeUTF(String str).