public static void main(String[] args) throws Exception {
writeObject();
readObject();
}
private static void readObject() throws IOException, ClassNotFoundException {
ObjectInputStream ois=new ObjectInputStream(new FileInputStream("11.txt"));
Object obj = ois.readObject();
Tetcher s= (Tetcher) obj;
System.out.println(s.getName()+","+s.getAge());
ois.close();
}
private static void writeObject() throws IOException {
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("11.txt"));
Tetcher s = new Tetcher("张三", 30);