此方法属于没有实现可序列化接口的类
public String FindVetsMedicalAppointments(String id){ MedicalBooking.getInstance().deserializeMedicalBooking();
for (int i = 0; i < MedicalBooking.mediBookings.size(); i++) {
MedicalBooking.getInstance().deserializeMedicalBooking();
if(MedicalBooking.mediBookings.get(i).getVetId().equals(id)){
System.out.println(MedicalBooking.getInstance().mediBookings.get(i).toString());
}
}
return "END OF APPOINTMENTS";
}
此方法位于实现可序列化接口的类
中 public void deserializeMedicalBooking(){
try{
FileInputStream fileIn = new FileInputStream("Medical Appointments.txt");
ObjectInputStream in = new ObjectInputStream(fileIn);
mediBookings = (ArrayList<MedicalBooking>) in.readObject();
} catch (ClassNotFoundException | IOException i) {}
}