my writer reader wont save data and add data to the file. When i run it all it does is overwrites the data. code is :
String add = nameField.getText(); String newLine = ("\n"); File file = new File("C:NewTest.dat"); try { // check whether the file is existed or not if (file.exists()) { // create a new file if the file is not existed file.createNewFile(); } // new a writer and point the writer to the file BufferedWriter writer = new BufferedWriter(new FileWriter(file)); // writer the content to the file writer.write(newLine); writer.write(add); // always remember to close the writer writer.close(); writer = null; } catch (IOException ab) { ab.printStackTrace(); } try { // new a reader and point the reader to the file BufferedReader reader = new BufferedReader(new FileReader(file)); nameArea.append(add + newLine); reader.close(); reader = null; } catch (FileNotFoundException ab) { ab.printStackTrace(); } catch (IOException ab) { ab.printStackTrace(); }