Try ObjectInputStream.readObject and cast the returned Object into your specific class type.
Joined: Mar 07, 2001
I keep getting a NullPointerException exception when I try to read the object. Here is the code: inbound = new ObjectInputStream(recTask.getInputStream()); message = (InCMsg)inbound.readObject(); "inbound" is an ObjectInputStream object, and "message" is of type InCMsg (a class I created). The client sends the object using: toStoreMsg = new ObjectOutputStream(connection.getOutputStream());
//send message to output stream to be received by StoreMsg toStoreMsg.writeObject(message); Here, toStoreMsg is an ObjectOutputStream object and message is of type InCMessage.
Joined: Feb 08, 2001
I guess either inbound = new ObjectInputStream(recTask.getInputStream()) returns null or recTask.GetInputStream() returns null. I can't know why, of course.
hi richard, i think you have to get a Socket object by accepting the object sent by clinet at your serverside, using accept() method of ServerSocket. after that, you need to get the InputStream using that socket object like InputStream ins=socketobject.getInputStream(); using the ins object, you have create the ObjectInputStream like this. ObjectInputStream ois=new ObjectInputStream(ins); and after that....its very easy to solve ur problem... HTH
Originally posted by Richard Robbins: I am trying to send an Object from a client to a server via a socket connection. How does one read the Object from the ObjectInputStream on the server side?