-3

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.

  • Can you be more specific at all? What do you want to know? – user253751 Aug 24 '15 at 05:54
  • 1
    An `InputStream` reads bytes, a `Reader` reads characters. Anything starting with `Buffered` uses a buffer. – Robby Cornelissen Aug 24 '15 at 05:58
  • Sometimes input is read only with inputStream, sometimes i find BufferedInputStream is created to read input. I want to know when to use what and why? and if any relation available between them. – optimus_Prime Aug 24 '15 at 06:01
  • inputStream-->readByte inputStreamReader-->reads directly char(ou u can say inputstream 8bit same time). BufferedInputstream-->readBytes only but fill the buffer so less system calls .. – Harish Aug 24 '15 at 06:09

1 Answers1

1

enter image description here

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.

Kashyap Kansara
  • 405
  • 4
  • 10
  • Thanks a lot Kansara. Every time i look for this things everywhere they explain it's implementation not why i should use. – optimus_Prime Aug 24 '15 at 06:08