-
Text file over written
I am trying to learn file handling in Java. I want to append text to the end of a file and tried following script:
Code:
BufferedWriter out = new BufferedWriter(new FileWriter("C:\\myFile.txt"));
out.write("aString");
out.close();
But the text file is overwritten. I know I can use RandomAccessFile to point to end of file and then append. Is this possible with BufferedWriter?
-
The FileWriter class api shows a couple of constructors that take a boolean append argument. You can find out what they do in the Constructor Detail section.
-
Thanks hardwired. It worked.
Code:
public FileWriter(String fileName,boolean append) throws IOException