与序列化有关的问题

huyanqieyu 2008-04-06 05:48:58
import java.io.*;
public class Piped
{

public static void main(String[] args)
{InputStream i=null;
OutputStream i2=null;
ObjectInputStream oi=null;
ObjectOutputStream oi2=null;
try
{
i=new FileInputStream("E:/nn.txt");

i2=new FileOutputStream("E:/nn.txt");
}
catch(IOException e)
{
e.getMessage();
}




try
{
oi=new ObjectInputStream(i);

}
catch(IOException e)
{

}
try
{
oi2=new ObjectOutputStream(i2);
}
catch(IOException e)
{
e.printStackTrace();
}
try
{
oi2.writeObject(new Per(100));
oi2.close();

}
catch(IOException e)
{
e.getMessage();
}
Per p=null;

try
{
p=(Per)oi.readObject();
oi.close();

}
catch(Exception e)
{
e.getMessage();
}
p.pp();


}

}
class Per implements Serializable
{
int i;
public void pp()
{
System.out.println(i);
}

Per(int j)
{
i=j;
}

Per()
{
i=500;
}
}
...全文
39 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
roader2046 2008-04-06
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 hmsuccess 的回复:]
问题是什么
[/Quote]
呵呵
hmsuccess 2008-04-06
  • 打赏
  • 举报
回复
问题是什么

62,623

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧