Java Java Data Structures Efficiency! Design the UI

Andre Kucharzyk
Andre Kucharzyk
4,479 Points

Can somebody say more about why we use new BufferedReader

I know documentation is linked in teachers notes but the way its written doesn't get to me. Why we use BufferedReader ?

Ryan Sherry
Ryan Sherry
12,448 Points

Hi Andre,

I'm still learning a lot and I'm far from an expert but I'll be happy to answer to the best of my ability:

https://docs.oracle.com/javase/8/docs/api/java/io/BufferedReader.html

It sounds like a BufferedReader is used to wrap around the InputStreamReader. From what I understand, technically, we don't need it but if we don't use it, then each read request made of a reader causes another read request to happen for the underlying character or byte stream. In other words, it uses up a ton of resources.

Wrapping it in a BufferedReader prevents this from happening and makes things much more efficient.

Here is more information on buffering in computer science:

https://en.wikipedia.org/wiki/Data_buffer