首先我把对象序列化保存到硬盘的一个位置后,这一步是正常的,然后,再读取它,也就是反序列化,总是报错
java.io.ioexceptionInputStream in = con.getInputStream();
objStream = new ObjectInputStream(in);
Object o = objStream.readObject();
也就是红字部分,程序到这里就报java.io.ioexception错误,请问有谁遇到过哦?
java.io.ioexceptionInputStream in = con.getInputStream();
objStream = new ObjectInputStream(in);
Object o = objStream.readObject();
也就是红字部分,程序到这里就报java.io.ioexception错误,请问有谁遇到过哦?
,贴出你序列化代码
因为我的序列化后的对象保存到服务器上的,每次使用时,总是先发出请求把服务器端得序列化对象下传到客户端进行解析
看下我服务端代码:
try {
ObjectOutputStream objStream = new ObjectOutputStream(out);
response.setContentType("application/x-java-serialized-object");
File file = new File(getSeizFile(seizKey));
LoadInformationBean loadInfo = null;
if (file.exists()) {
ObjectInputStream in = new ObjectInputStream(
new FileInputStream(file));
Object o = null;
try {
o = in.readObject();
} catch (Exception e) {
out.close();
e.printStackTrace();
} finally {
out.close();
}
if (o != null) {
loadInfo = (LoadInformationBean) o;
}
}
objStream.writeObject(loadInfo); out.flush(); out.close();
}
首先,我这个序列化对象保存的是list集合我跟踪发现,这边读取服务端的序列化对象的文件时候,没有报错,但list集合的size为0,表示数据已经不存在了,请问我这代码有什么问题吗?
objectinputstream readobject eofexception
好像跟读取的文件没有正确的结束符有关,请求大家怎么解决此类问题的哦