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

Kevin Faust
Kevin Faust
15,353 Points

more information on this: new BufferedReader (new InputStreamReader(System.in));

new BufferedReader (new InputStreamReader(System.in));

i have no idea what this does and why we need it

2 Answers

Rob Bridges
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 Points

Hey Kevin,

What that line of code is effectively doing is using the Buffered Reader Class to set up an input steam that we can utilzye to read input from the keyboard.

A buffered reader is simply a class that we can call to help us read input from the keyboard for base Input output type of programs. at treehouse we've been using console.readLine(); but you'll find when you move to IDE's that console actually doesn't work. In which case we use one of two classes.

Buffered Reader

Or Scanner

Both of these classes assist with reading input type that is passed into the program.

Kevin Faust
Kevin Faust
15,353 Points

hey rob, thanks

is using BufferedReader and InputStreamReader the most common way to take in input?

Rob Bridges
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Rob Bridges
Full Stack JavaScript Techdegree Graduate 35,467 Points

Hey Kevin,

Personally I like buffered Reader myself, but there are many people out there who use Scanner, I will use Scanner in the event that the input I am grabbing needs to be broken apart and looked at the word by word. this would be a job for the Scanner as it's better at breaking things down and buffered reader has trouble in that department.

However if you really just want to get the contents buffered reader would be better at this.