所以我正在编写一个程序,它将接受游戏名称、发行商和价格(作为字符串)返回到一个已经有一些记录的文件中。但是,当我运行该程序时,它会删除以前的记录。
//open the output stream
FileWriter writeFile = new FileWriter(inFile);
BufferedWriter lineWriter = new BufferedWriter(writeFile);
PrintWriter printLine = new PrintWriter(lineWriter);
if (menuItem == ADD_GAME)
{ //Get game
System.out.print("Enter name of game: ");
gameName = Keyboard.readString();
//get publisher
System.out.print("Enter name of publisher: ");
publisherName = Keyboard.readString();
//get price of game
System.out.print("Enter game price: ");
gamePrice = Keyboard.readString();
//add game to games
createdGame.addGame(gameName, publisherName, gamePrice);
//add game to file record
outLine = gameName + " " + publisherName + " " + gamePrice;
printLine.println(outLine);
}