私はいくつかのレコードを持つファイル DataFile.txt を持っています。新しいエントリを追加すると、他のすべてのレコードがクリアされ、新しいレコードのみが保存されます。しかし、私はそのレコードを追加したいです。
private void saveFile()
      {
        try
        {
            PrintWriter out = new PrintWriter(new FileWriter("DataFile.txt"));
            String name ="";
            String ID="";
            String roomType ="";
            String meal="";
            int days=0;
            int tprice=0;
            for (int i = 0; i < myList.size(); i++)
            {
                Customer c = myList.get(i);
                name = c.getName();
                ID = c.getID();
                roomType = c.getRoomItem();
                meal = c.getMealItem();
                days = c.getDaysIndex();
                tprice = c.getTotalPrice();
                out.println(name + "," + ID+ "," + roomType+ "," + meal+ "," + days+ "," + tprice);
            }
            out.close();
            JOptionPane.showMessageDialog(null,"Data saved successfully!","",
                                                              JOptionPane.INFORMATION_MESSAGE);
          }
          catch (Exception ex)
          {
             System.out.println("save file fail");
          }
      } //end of the method
ありがとう。