如何序列化整个列表呢?无需序列化列表中的每个对象。
public void searilizePlant(ArrayList<Plant> _plants) { try { FileOutputStream fileOut = new FileOutputStream(fileName); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeObject(_plants); out.close(); fileOut.close(); } catch (IOException ex) { }}public List<Plant> deserializePlant() { List<Plants> plants = null; try { ObjectInputStream in = new ObjectInputStream(new FileInputStream(fileName)); plants = in.readObject(); in.close(); } catch(Exception e) {} return plants;}如果那不能解决您的问题,请发布有关您的错误的更多详细信息。



