[Java] IO-05 ObjectIO (java 对象序列化)
2013-12-07 14:37
561 查看
import java.io.*; public class TestObjectIO { public static void main(String args[]) throws Exception { T t = new T(); t.k = 8; FileOutputStream fos = new FileOutputStream( "d:/share/java/testobjectio.dat"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(t); oos.flush(); oos.close(); FileInputStream fis = new FileInputStream( "d:/share/java/testobjectio.dat"); ObjectInputStream ois = new ObjectInputStream(fis); T tReaded = (T) ois.readObject(); System.out.println(tReaded.i + " " + tReaded.j + " " + tReaded.d + " " + tReaded.k); } } class T implements Serializable { int i = 10; int j = 9; double d = 2.3; transient int k = 15; }
相关文章推荐
- [Java] IO-05 ObjectIO (java 对象序列化)
- java IO之对象的序列化和反序列化
- 【JAVA IO】_对象序列化笔记
- JAVA IO——对象序列化解析及项目实战
- Java学习笔记——IO操作之对象序列化及反序列化
- Java IO之对象的序列化、ObjectInputStream和ObjectOutputStream类
- java IO(三):数据操作流、合并流、回退流、对象序列化、字符编码问题、压缩流
- JavaIO 6—对象的序列化
- Java的IO操作(三) - 对象的序列化、ObjectInputStream和ObjectOutputStream类
- java IO之Print、Scanner和对象序列化
- 『黑马程序员』---java--IO--对象序列化-管道流
- java io (六) 对象序列化,反序列化 -- Serializable接口
- Java的IO操作(三) - 对象的序列化、ObjectInputStream和ObjectOutputStream类
- 对象序列化中java.io.InvalidClassException的解决方法
- Java IO _对象序列化
- python的io 与java的io流的使用及对象的序列化
- Java中对象的序列化(实现java.io.Serializable)
- java.io.NotSerializableException: 没实现序列化对象而写入文件流的报错
- Java的对象序列化以及文件IO处理
- Java笔记5 IO<4>对象的序列化、管道流