Return to site

JAVA INTERVIEW QUESTION: What is the difference between IO and NIO?

· java

Define

  • Java IO (Input/Output) is a collection of classes and interfaces which you may use to perform almost every possible IO operation through your java application. 
  • Java NIO is the new input/output (NIO) library that was introduced with JDK 1.4.

Difference

The main difference between NIO and IO is that NIO provides asynchronous, non blocking IO, which is critical to write faster and scalable networking systems. While most of utility from IO classes are blocking and slow. NIO take advantage of asynchronous system calls in UNIX systems such as select() system call for network sockets. Using select(), an application can monitor several resources at the same time and can also poll for network activity without blocking. The select() system call identifies if data is pending or not, then read() or write() may be used knowing that they will complete immediately.

All Posts
×

Almost done…

We just sent you an email. Please click the link in the email to confirm your subscription!

OK