What is the difference between stream-based Input and Channel-Based Input? The java API provides both stream-based in "java.io" package and channel-based in "java.nio" package. Which one of the two is better in performance and reduced run-time errors?

  • did you check the 'nio' tag wiki at Stack Overflow? "NIO stands for 'New I/O'. It was introduced in JDK 1.4 in the java.nio package. It comprises several elements:..." – gnat Jun 14 '12 at 15:07
  • 1
    this is a good question, 10 years ago ... the short answer is it depends, there is plenty of extensive documentation on when to use which technology, both are still around because they a better at different things. Long answer Google has everything you need to know. – user7519 Jun 14 '12 at 15:47
  • I think that this serves as a good gateway question. The OP is one of today's lucky 10,000. – Gary Rowe Jun 15 '12 at 12:10
  • According to stackoverflow.com/questions/2810156/concepts-channel-vs-stream - channel is message oriented while stream is byte oriented, and probably does not know how to divide the messages. Another difference, that channels store messages while streams don't. – inf3rno Aug 6 '14 at 20:59

See this Oracle blog post for a good overview

Also don't neglect to read up on Java 7's NIO.2 APIs!

In terms of performance etc, well the answer is, "it depends". It depends on the characteristics of your I/O, e.g. it's size, it's 'shape', whether it's Network or disc or in memory or ....


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.