> Have a look at RandomAccesFile class documentation,
> in particular at writeBytes, seek and getFilePointer
> methods!
Wow. Just the right methods to append some lines of text to a file.
> you should be able to add a line at the end of the
> file, without reading and writing the whole file!
Who said you have to?
Thank you, it worked out really easy with FileWriter
public static void insertLineToFile (String line, String filename)
{
FileWriter fr = null;
try {
fr = new FileWriter(filename, true);
fr.write(line + "\n");
fr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
Thank you, it worked out really easy with FileWriter
public static void insertLineToFile (String line, String filename)
{
FileWriter fr = null;
try {
fr = new FileWriter(filename, true);
fr.write(line + "\n");
fr.close();
} catch (IOException e) {
e.printStackTrace();
}
}