Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Java NIO advantages if there is a single client and complete object read is required
- // Reading from socket
- private SomeObject readObject() throws IOException, ClassNotFoundException {
- Object object = oiStream.readObject();
- if (object != null && object instanceof SomeObject) {
- SomeObject someObject = (SomeObject) object;
- return someObject;
- }
- return null;
- }
- // Writing to socket
- public void writeToSocket(SomeObject someObject) throws IOException {
- if (isSocketOpen()) {
- ooStream.writeObject(someObject);
- ooStream.flush();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment