ObjectInputStream反序列化先前使用ObjectOutputStream编写的原始数据和对象
ObjectInputStream(InputStream in):创建从指定的InputStream读取的ObjectInputStream
Object readObject():从ObjectInputStream读取一个对象
public class Test1 { public static void main(String[] args) throws IOException, ClassNotFoundException { ObjectInputStream ois = new ObjectInputStream(new FileInputStream("oos.txt")); Object obj = ois.readObject(); Student s = (Student) obj; System.out.println(s.getName()+","+s.getAge()); ois.close(); } }