Why are NIO FileChannels created from InputStream/OutputStream
FileChannel in Java implements both ReadableByteChannel and
WritableByteChannel, which makes them bi-directional.
Question:
To create a FileChannel, I need FileInputStream(for reading) and
FileOutputStream(for writing). Doesnt that defeat the purpose of making
them bi-directional, since I need to instantiate both the streams?
Follow up Question:
I've seen references at many places stating that java.io is stream
oriented, and java.nio is block oriented(Here). Then why are they
instantiated through InputStream and OutputStream? Is the block oriented
notion, just an abstraction over Streams?
No comments:
Post a Comment