
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);
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)