文章标题
来源:互联网 发布:windows update有用吗 编辑:程序博客网 时间:2024/06/06 19:12
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/io/testobjectio.dat" ); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(t); oos.flush(); oos.close(); FileInputStream fis = new FileInputStream("d:/share/java/io/testobjectio.dat" ); ObjectInputStream ois = new ObjectInputStream(fis); T tReaded = (T)ois.readObject(); //读出来是object类型的,强制转换成T类型 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; int k = 15;}
0 0
- 文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题 文章标题 文章标题 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 文章标题
- 读书笔记之c和指针(4)
- HDU 5360 Hiking (贪心+优先队列)
- listview 中item 加入 其他触发点击事件的widtget 冲突
- 用IoAllocateIrp创建IRP
- 如何生成KeyStore
- 文章标题
- Linux 常用编辑器之vim
- SqlServer中in和exists的区别效率问题
- 杭电(hdu)ACM 1231 最大连续子序列
- HDOJ 2020 绝对值排序 (水)
- java 代码中如何预防空指针异常
- java基础--集合
- Redis3.0--集群安装部署
- iOS 第八课 iOS开发常用尺寸