Search code examples
javajava-io

In JAVA what is meaning of System.in get wrapped in BufferReader object?


I'm reading Herbert Schildt book for Java in input-output portion of Java there's written that:

wrap System.in in a BufferedReader object

What's meaning of this object technically?


Solution

  • BufferedReader object is an object that uses a buffer memory for input operations. Wrapping here refers to essentially using the BufferedReader object to handle the input operations rather than directly dealing with the InputStream. This increases the speed and simplicity of the code as we have to deal with chunks of data rather than individual bytes. BufferedReader does not work on its own, under the hood it needs an InputStream to work on the lower levels, that's why the BufferedReader is wrapped around System.in stream.