java对象流ObjectStream
来源:互联网 发布:js 24小时时间插件 编辑:程序博客网 时间:2024/05/01 07:33
package com.wj.objectstream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.io.Serializable;
/**
*
* @author wJing
* time:2014-2-18 22:54:59
* ObjectStream
*/
public class ObjectStreamDemo1 {
public static void main(String[] args) throws Exception {
writeObject();
//readObject();
}
public static void writeObject() throws FileNotFoundException, IOException {
ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("d:\\obj.txt"));
oos.writeObject(new Person("zhangsan",30));
oos.close();
}
public static void readObject() throws FileNotFoundException, IOException, Exception {
ObjectInputStream ois = new ObjectInputStream(new FileInputStream("d:\\obj.txt"));
Person p = (Person)ois.readObject();
System.out.println(p.toString());
ois.close();
}
}
class Person implements Serializable {
private String person;
private int age;
public Person(String person, int age) {
this.age = age;
this.person = person;
}
@Override
public String toString() {
return "Person [person=" + person + ", age=" + age + "]";
}
}
0 0
- java对象流ObjectStream
- Java IO流:转化流InputStramReader,数据流DataStream,对象流ObjectStream
- java-ObjectStream初步认识
- ObjectStream
- (92)操作对象流ObjectStream、管道流PipedStream、任意流RandomStream
- 黑马程序员_java基础篇操作对象ObjectStream,管道流,随机存储Day5(下)
- java IO流 ObjectStream PipedStream 随机访问文件 字符编码--21
- Java中ObjectStream序列化实现
- Java 使用 ObjectStream 时的注意事项
- IO流(ObjectStream流数据)
- JAVA程序开发小经验 - 使用ObjectStream会出现的问题
- IO(打印流、序列流、ObjectStream、管道流、RandomAccessFile、DataStream、ByteArrayStream)
- I/O(四)ObjectStream
- ObjectStream的使用
- JavaIO之ObjectStream(一)
- 使用ObjectStream会出现的问题
- 对象流(Java)
- JAVA中的流对象
- Logistic Regression--逻辑回归算法汇总**
- 联想品牌机重装系统的经验总结
- Unity3D 美术资源规范
- 【Leetcode】Word Ladder
- LingPipe使用笔记
- java对象流ObjectStream
- VS2010导入SQL数据库
- 需要阅读的好书
- VC中数字与字符串转换方法
- 软件本身呢对shellcode 检查 SEH Exploit学习
- java随机读取文件的内容
- 访问:67583次
- 布下了阴影
- 局部变量与全局变量的困惑