import java.lang.*;
import java.util.*;
import java.io.*;
public class dd{
public static void main(String args[]) throws Exception{

FileOutputStream fo = new FileOutputStream("D://cola//dat");
DataOutputStream dos = new DataOutputStream(fo);
dos.writeInt(200);
dos.writeUTF("hello");
dos.flush();
dos.close();

DataInputStream dis = new DataInputStream(new FileInputStream("D://cola//dat"));
System.out.println(dis.readInt());
System.out.println(dis.readUTF());
dis.close();

ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("D://cola//date"));
oos.writeObject(new Date());
oos.close();

ObjectInputStream ois = new ObjectInputStream(new FileInputStream("D://cola//date"));
Date d = (Date)ois.readObject();
ois.close();
System.out.println(d);

ObjectOutputStream ooss = new ObjectOutputStream(new FileOutputStream("D://cola//student"));
ooss.writeObject(new Student("jia",11));
ooss.close();

ObjectInputStream oiss = new ObjectInputStream(new FileInputStream("D://cola//student"));
Student st=(Student)oiss.readObject();
oiss.close();
System.out.println(st.getName()+" "+st.getAge());
}
}

class Student implements Serializable{ //类必须实现序列化 存储本地唯一标示
private String name =null;
private int age;
public Student(String name,int age){
this.name=name;
this.age = age;
}
public String getName(){
return name;
}

public int getAge(){
return age;
}
}