序列化
来源:互联网 发布:淘宝双11是什么意思啊 编辑:程序博客网 时间:2024/06/11 20:03
package class1;
import java.io.File;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
public class SerDemo01 {
public static void main(String args[]) throws Exception {
File f = new File("d:" + File.separator + "test.txt") ;
ObjectOutputStream oos = null;
OutputStream out = new FileOutputStream(f) ;
oos = new ObjectOutputStream(out) ;
oos.writeObject(new PersonS("张三",30)) ;
oos.close() ;
}
import java.io.File;
import java.io.FileOutputStream;
import java.io.ObjectOutputStream;
import java.io.OutputStream;
public class SerDemo01 {
public static void main(String args[]) throws Exception {
File f = new File("d:" + File.separator + "test.txt") ;
ObjectOutputStream oos = null;
OutputStream out = new FileOutputStream(f) ;
oos = new ObjectOutputStream(out) ;
oos.writeObject(new PersonS("张三",30)) ;
oos.close() ;
}
}
反序列化
package class1;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.ObjectInputStream;
public class SerDemo {
public static void main(String[] args) throws Exception {
File f = new File("d:" + File.separator + "test.txt") ;
ObjectInputStream ois = null;
InputStream input = new FileInputStream(f);
ois = new ObjectInputStream(input) ;
Object obj = ois.readObject();
ois.close();
System.out.println(obj);
}
}
阅读全文
0 0
- 序列化
- 序列化
- 序列化
- 序列化
- 序列化
- 序列化
- 序列化
- 序列化
- 序列化
- 序列化
- 序列化
- 序列化
- 序列化
- 序列化
- 序列化
- 序列化
- 序列化
- 序列化
- rz -bey
- 计算机网络----- 协议层次
- java.lang.ClassNotFoundException: ch.qos.logback.classic.spi.ThrowableProxy
- OracleRAC集群SCAN说明
- tensorflow-mnist数据集训练
- 序列化
- layuicms 后台管理系统中,右侧子窗口的链接在tab选项卡中打开
- 正则表达式 ---判断非空
- UVA 1515Pool construction
- 全栈和前后端分析
- 让职场新人速成的5大狠招!
- PhantomJS API 第一篇
- 分享一个很好用的 输出日志的类
- 快捷键