public void recordObject() { File myFile = new File("history.txt"); PrintWriter output = null; Scanner in = null; if(!myFile.exists()) { // the file dosent exist try { myFile.createNewFile(); // file created } catch (IOException e) { System.out.println("a error occured"); System.exit(0); } } else { // file exists try { output = new PrintWriter(myFile); } catch (FileNotFoundException e) { System.out.println("Error with opening the file program closing"); System.exit(0); } // file opened output.append("<<1>> new prosses"); output.close(); }
what have i done wrong in this method i am trying to append to the text file and for some reason it just keeps overwriting what i have in the file.
thanks dale