0

hey everyone,
well i got a little problem im trying to write input from the JTextField into the file (file4.txt) but the problem is it keeps overwriting the text file each time i make input and any data ther was is changed in to new data.all i need is that it would add the new information below the old information.
any suggestions?

public void actionPerformed(ActionEvent e) {
String nameText = enterName.getText();
try
    { 
      BufferedWriter bufewr;
      bufewr         = new BufferedWriter(new FileWriter("file4.txt"));
      for (int i=0; i<1; i++)
      { bufewr.write(nameText);
        bufewr.newLine();
        System.out.println("string= " + nameText);
      }

      bufewr.flush();
      bufewr.close();
    }
    catch(IOException e)
    { System.err.println("Exception: " + e.getMessage());
      System.exit(1);
    }
  }

any suggestion would be greatly appreciated
thank you

2
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by gedas
0

wow this was easy didn't expect that to be so simple thank you very much
thank YOU

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.