Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Java Java Data Structures - Retired 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 ?

1 Answer

Ryan Sherry
Ryan Sherry
12,449 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