Guest User

Untitled

a guest
May 5th, 2012
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. Java NIO advantages if there is a single client and complete object read is required
  2. // Reading from socket
  3. private SomeObject readObject() throws IOException, ClassNotFoundException {
  4. Object object = oiStream.readObject();
  5. if (object != null && object instanceof SomeObject) {
  6. SomeObject someObject = (SomeObject) object;
  7. return someObject;
  8. }
  9. return null;
  10. }
  11.  
  12. // Writing to socket
  13. public void writeToSocket(SomeObject someObject) throws IOException {
  14. if (isSocketOpen()) {
  15. ooStream.writeObject(someObject);
  16. ooStream.flush();
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment