当前位置: 技术问答>java相关
ObjectOutputStream问题,怎样把一个对象存成文件.
来源: 互联网 发布时间:2015-06-09
本文导语: grobj i;//This class figure link list. clist.ghead = null; clist.gtail = null; for(i = glist.ghead;i!=null;i=i.next) i.copy(clist); try { FileOutputStream fileOut = new FileOutputStream("1.txt"); ObjectOutputStream out = new ObjectOutputStream(fileOut); out.writeOb...
grobj i;//This class figure link list.
clist.ghead = null;
clist.gtail = null;
for(i = glist.ghead;i!=null;i=i.next)
i.copy(clist);
try
{
FileOutputStream fileOut = new FileOutputStream("1.txt");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(clist);
}
catch(Exception event)
{
//......略
}
clist.ghead = null;
clist.gtail = null;
for(i = glist.ghead;i!=null;i=i.next)
i.copy(clist);
try
{
FileOutputStream fileOut = new FileOutputStream("1.txt");
ObjectOutputStream out = new ObjectOutputStream(fileOut);
out.writeObject(clist);
}
catch(Exception event)
{
//......略
}
|
qq:2676250你直接来找我
|
不好意思!
看错了!
你implement了Serializable接口没有?
森么提示?
看错了!
你implement了Serializable接口没有?
森么提示?
|
//向文件进行对象串行化
public static void ObjectOutputtoFile(String filename,JJMatrix outMatrix) throws IOException
{
ObjectOutputStream objectOut=new ObjectOutputStream(
new BufferedOutputStream(
new FileOutputStream(filename)));
objectOut.writeObject(outMatrix);
objectOut.close();
}
有问题再和我联系!
public static void ObjectOutputtoFile(String filename,JJMatrix outMatrix) throws IOException
{
ObjectOutputStream objectOut=new ObjectOutputStream(
new BufferedOutputStream(
new FileOutputStream(filename)));
objectOut.writeObject(outMatrix);
objectOut.close();
}
有问题再和我联系!