Is it possible to write text to a file without overwriting previous data?
What I have done always is:
StringBuffer sb = new StringBuffer();
BufferedReader in;
PrintWriter out;
try{
in = new BufferedReader( new FileReader("somefile.txt"));
out = new PrintWriter( new FileWriter("somefile.txt"));
String input = "";
while(input != null){
sb.append(input + "\n");
input = in.readLine();
}
in.close()
out.print(sb.toString());
// now start doing what I want.
Is this the correct way?