java - why read and write are the only abstract methods in InputStream and OutputStream -
only read() , write(int x) methods abstract in inputstream , outputstream?
so,why read() , write(int x) only abstract methods in inputstream , outputstream
as javadoc inputstream says,
applications need define subclass of inputstream must provide method returns next byte of input.
all other methods (e.g. read multiple bytes) can implemented using read(). i.e. if provide implementation read new source (e.g. perhaps new bit of hardware) need provide means read single byte. inputstream provides other mechanisms around this.
note other methods aren't final. subclasses can provide more efficient implementations of (say) reading multiple bytes, don't have to.
the same apply outputstream
java io
No comments:
Post a Comment