November 2006
Intermediate to advanced
224 pages
3h 29m
English
ObjectInputStream in = new ObjectInputStream(socket.getInputStream()); Object o = in.readObject(); |
Java enables object instances to be serialized and written either to a file or across a network. In this phrase, we show how you can read from a network socket an object that has been serialized. This phrase assumes that we’ve previously created a socket to the server with which we want to communicate. See the phrase “Contacting a Server” in this chapter for more details on creating the socket instance.
In this phrase, we call the getInputStream() method of the socket instance to get a reference to the socket’s input stream. Using this, we can instantiate an ObjectInputStream instance. The ObjectInputStream class is used ...
Read now
Unlock full access