Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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 ?

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