我已设法在下面的文件中保存两条独立的信息。但我很想知道如何编辑此文件中的信息。
try {
RandomAccessFile fileWriter = new RandomAccessFile("Officers.txt", "rw");
fileWriter.seek(fileWriter.length());
fileWriter.writeUTF(officerObject.getOfficerBadgeNum());
fileWriter.writeUTF(officerObject.getOfficerFirstName());
fileWriter.writeUTF(officerObject.getOfficerLastName());
fileWriter.writeUTF(officerObject.getOfficerPrecint());
fileWriter.close();
System.out.println("Data Successfully Saved");
}
catch (IOException e) {
System.out.println("Error in File. Could not SAVE Officer");
e.printStackTrace();
}