I recall a thread specifically saying that NIO was prohibitted or borderline questionable to use so I would suggest you stay clear of using it and stick with the defacto acceptable IO standard for the exam, RandomAccessFile.
This has been a topic of debate for some time. Despite what Sun's website says, several people have contacted Sun through the email@example.com address and asked about NIO. Sun's response has been that you can use NIO as long as the instructions you downloaded do not specifically forbid it. Check out this thread for Andrew's take on it.
If you are still a little unsure about NIO, and really want to use it in your assignment, email Sun yourself, and include their response in your choices documentation.
“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook
I sent them an e-mail today. I'm very interested to see what they say, because the same section that bans NIO bans other technologies too. Their response could alter my networking layer (for the better!).
Interestingly, while my instructions do not explicitly ban NIO, they do state that I have only two choices for networking, sockets or RMI. Hmm. [ January 19, 2005: Message edited by: Jeff Bosch ]
Give a man a fish, he'll eat for one day. Teach a man to fish, he'll drink all your beer.
Cheers, Jeff (SCJP 1.4 all those years ago...)
To reiterate what I said in a previous thread about NIO. Even if Sun says you can use it, this is a bad choice for networking since it provides nothing of benefit to this assignment and actually gets in the way.
Even though its similar to the time honoured way to code sockets in Unix C, NIO is not dependable in JDK 1.4, it gets close by 1.4.2 and appears to work properly in 1.5. There are lots of pitfalls, especially for those who are not familiar with non-blocking socket I/O. If you don't believe me read the bug parade and the NIO messages on the Sun Java Forum.
Lots of fun and games here. NIO non-blocking I/O works best in a single thread. The main advantage of the non-blocking I/O is that you won't need all those threads. But if you need them anyway, expect problems. See the comments about register() and interestOps(). You need a queue to deal with these.
NIO is not stream oriented, so you can't wrap an ObjectInputStream around it, there is a way, but you lose the non-blocking mode, so its hardly worth it. You will need to build a means of sending a serialized object or define a protocol that can transfer an array of character strings as a single byte array. Fun if you are into that sort of thing, but much more difficult than using ObjectInputStream, stream oriented sockets and thread.