严重:null java.io.EOFException无法从Java中的ObjectInputStream读取两次值

时间:2018-10-10 21:58:09

标签: java object client-server objectinputstream objectoutputstream

我正在尝试读取服务器上从客户端发送的值。第一次工作正常,但再次阅读会出现异常。

客户代码:

String extension=getFileExtension(file);
OutputStream out;
out = socket.getOutputStream();
ObjectOutputStream oout = new ObjectOutputStream(out);
oout.writeObject(extension);

服务器代码

String extension="";
InputStream in;
in = socket.getInputStream();
ObjectInputStream iin = new ObjectInputStream(in);//It gives exception here second time in same running the program
extension = (String)iin.readObject();

0 个答案:

没有答案