File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes IO or NIO? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "IO or NIO?" Watch "IO or NIO?" New topic
Author

IO or NIO?

Jason Hocker
Ranch Hand

Joined: Jul 23, 2003
Posts: 132
I thought I've heard, and in Max's book, that its the option of the developer to chose old IO or NIO. But as I go to purchase the "exam", I see...

APIs relevant to the assignment
The assignment generally requires that you can write code using the Java programming language, using any and all constructions. You must also be able to make reasonable use of the following additional facilities and APIs:
Thread handling and synchronization
Swing (and AWT to the extent necessary to support Swing)
Standard file IO (java.io, not java.nio)
Either: Socket-based network programming and serialization _or_ Java RMI (Java Remote Method Invocation) (your choice of one or the other, not both).
The following APIs and facilities may not be used:
Enterprise JavaBeans
Servlets, JSP technology, or any other web-oriented APIs
NIO, the New IO facilities
Java DataBase Connectivity (JDBC) and SQL
Java IDL API and CORBA
Third party software libraries or tools (such as browsers)

http://suned.sun.com/US/catalog/courses/CX-310-252A.html
Is NIO out?
[Andrew: Changed [code] blocks to [quote] blocks so that horizontal scrolling is not required]
[ March 18, 2004: Message edited by: Andrew Monkhouse ]
George Marinkovich
Ranch Hand

Joined: Apr 15, 2003
Posts: 619
Hi Jay,
I've quoted the same statement you quoted above so that it is easier to
read. When you put it in <code> and </code> tags (rather than quote tags)
it unfortunately suppressed word wrapping. So if you edit your post and
replace the code tags with quote tags word wrapping will be restored and
everyone will be able to read your post easily.

APIs relevant to the assignment
The assignment generally requires that you can write code using the Java
programming language, using any and all constructions. You must also be
able to make reasonable use of the following additional facilities and
APIs:
Thread handling and synchronization
Swing (and AWT to the extent necessary to support Swing)
Standard file IO (java.io, not java.nio)
Either: Socket-based network programming and serialization _or_ Java RMI
(Java Remote Method Invocation) (your choice of one or the other, not
both).
The following APIs and facilities may not be used:
Enterprise JavaBeans
Servlets, JSP technology, or any other web-oriented APIs
NIO, the New IO facilities
Java DataBase Connectivity (JDBC) and SQL
Java IDL API and CORBA
Third party software libraries or tools (such as browsers)

Is NIO out?
For you, the answer is probably. You will find out for sure when you
actually download the assignment, but it's clearly Sun's intention in
future assignments to restrict the use of NIO.
The following is true for everyone: You are held responsible only for
what is said in your assignment instructions. If you look at your
assignment instructions (the instructions.html file downloaded from Sun)
and it does not explicitly say that you cannot use NIO, then you can use
NIO. You might want to use Edit-> (Find on this page)... to search
for "NIO" in your assignment instructions. If you find it in your
instructions and they say you're prohibited from using it, then you are.
If you don't find it in your instructions you may use it.
This is primarily to benefit those who have already downloaded their
assigments (before that notice that you quoted from was available) and had
no idea that NIO was prohibited because their assignment instructions made
no mention of it.


Regards, George
SCJP, SCJD, SCWCD, SCBCD
Morgan Bath
Ranch Hand

Joined: Jan 16, 2004
Posts: 196
NIO was ok for a brief time, then they banned it for some uber-odd reason (perhaps the programmers at Sun dont know that API yet). If you downloaded before a certain point in time you could use it, if not then you cant. Like George said, search your instructions cos if you cant use it, it will definately be listed there.
However if you have not already downloaded I would suggest you 99% forget about using this porject as a good platform to learn about NIO. Which is a shame, cos its really rather nifty
morgan


Morgan
SCJP (1.4), SCJD (1.4), SCWCD (1.3), SCBCD (1.3)
Simon Ingram
Ranch Hand

Joined: Nov 30, 2003
Posts: 173
Hi guys,
I decided to upgrade my project to NIO before I heard that Sun was closing the door on it. By this I mean that I have used file channels and byte buffers to do the same thing I was doing before with a raf (RandomAccessFile). Apart from this I don't do anything in my code that takes advantage of NIO, like interrupting threads or network connections. In short, I don't really know what NIO is doing for me. Max said that NIO offers the advantage of improved performance and non blocking IO for network connections. It also allows threads and IO to be interrupted, although I do nothing to cause such interruptions. What do you reckon, my fellow ranchers? Should I strip the NIO code out and go back to using my raf? Or does the mere use of channels for access to the binary file confer performance gains that are worth keeping?
Simon
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11526
    
100

Hi Simon,
Why do you want to remove NIO?
If your instructions expressly forbid you to use NIO, then you must remove all usage of it. However if your instructions do not mention NIO, then you are free to use it.
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Simon Ingram
Ranch Hand

Joined: Nov 30, 2003
Posts: 173
Hi Andrew,
My instructions do not forbid the use of NIO. I was going to take it out because my impression from this and other posts on the subject suggested that Sun didn't like it, so, you know, why upset them? I am using NIO only to read and write to and from the binary file. Generally NIO is used in conjunction with sockets, but I am using RMI for the networking, so, to be frank, I am beginning to doubt my design. What do you think? Can I justify using NIO in the limited way I have done, or should I just strip it out?
Simon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: IO or NIO?