package zzy;
import java.io.*;
import static java.lang.System.*;
/**
*
* @author Zhu Zhengyan
*/
public class zzy13 {
public static void main(String args[])throws IOException
{
try
{
FileOutputStream a = new FileOutputStream("d:/linshi/qu");
ObjectOutputStream b = new ObjectOutputStream(a);
ufo g = new ufo(5,"j");
b.writeObject(g);
a.close();
}
catch(Exception e)
{
out.println("Exception"+ e);
}
try
{
FileInputStream c = new FileInputStream("d:/linshi/qu");
ObjectInputStream d = new ObjectInputStream(c);
ufo h = (ufo)d.readObject();
h.show();
c.close();
}
catch(Exception e)
{
out.println("Exception"+ e);
}
}
}
class ufo implements Serializable //注意这个接口
{
private int n;
private String m;
public ufo(int n,String m){
this.n = n;
this.m = m;
}
public void show()
{
out.println(m+"\t"+n);
}
}
import java.io.*;
import static java.lang.System.*;
/**
*
* @author Zhu Zhengyan
*/
public class zzy13 {
public static void main(String args[])throws IOException
{
try
{
FileOutputStream a = new FileOutputStream("d:/linshi/qu");
ObjectOutputStream b = new ObjectOutputStream(a);
ufo g = new ufo(5,"j");
b.writeObject(g);
a.close();
}
catch(Exception e)
{
out.println("Exception"+ e);
}
try
{
FileInputStream c = new FileInputStream("d:/linshi/qu");
ObjectInputStream d = new ObjectInputStream(c);
ufo h = (ufo)d.readObject();
h.show();
c.close();
}
catch(Exception e)
{
out.println("Exception"+ e);
}
}
}
class ufo implements Serializable //注意这个接口
{
private int n;
private String m;
public ufo(int n,String m){
this.n = n;
this.m = m;
}
public void show()
{
out.println(m+"\t"+n);
}
}