public static void main(String[] args) throws IOException, Exception {
//将集合对象一次读取
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("person.txt"));
ArrayList<Person> list = (ArrayList<Person>)ois.readObject();
for (Person person : list) {
System.out.println(person);
}
ois.close();
} |
|