I always get confused when to process my input data how, which process. Different times i find different solutions. I am also not clear about their Hierarchy.
What is the relation between InputStream, BuffreredInputStream, InputStreamReader and BufferedReader? [closed]
Asked Answered
InputStream is parent class of all input streams and readers. Classes that have Stream keyword will work with bytes whereas classes which have Reader keyword will work with characters.
Buffer is wrapper around these streams to decrease the system calls and increase performance and speed of reading.
Non buffered streams return single byte each time whereas Bufferd stream will not return until the buffer gets full.
For example if you take BufferedReader you can read a whole line using readLine()
but in non buffered stream you must read single character using read()
method.
Thanks a lot Kansara. Every time i look for this things everywhere they explain it's implementation not why i should use. –
Lamrert
© 2022 - 2024 — McMap. All rights reserved.
InputStream
reads bytes, aReader
reads characters. Anything starting withBuffered
uses a buffer. – Twodimensional