you can judge the file whether or not empty
if the file is empty,you add the new data.
if the file is not empty,you move the pointer to the end of file,and then add the new data after old data.
sorry,my english speeking is so weak.(-_-)!
if the file is empty,you add the new data.
if the file is not empty,you move the pointer to the end of file,and then add the new data after old data.
sorry,my english speeking is so weak.(-_-)!
import java.io.*;
... try{
File file = new File("D:/test/Test.java");
String appendStr = "Append in the end";
RandomAccessFile ras= new RandomAccessFile(file,"rw");
long length = file.length ();
ras.seek ((int)length);
ras.write (appendStr.getBytes ());
}catch(IOException ex){
ex.printStackTrace ();
}finally{
try{
ras.close();
}catch(Exception ex){}
}