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?
4
-
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
-
1this 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
Add a comment
|
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 ....
-
9Here the link to the archive: web.archive.org/web/20140528182031/https://blogs.oracle.com/slc/… - That's why answers here should be able to work without their links btw – piegames Sep 27 '17 at 13:49
-
Can we achieve parallel reads from File to make the read faster. its CSV file – Mubasher Apr 2 '20 at 12:22