This week's book giveaways are in the Scala and Android forums.
We're giving away four copies each of Machine Learning Systems: Designs that scale and Xamarin in Action: Creating native cross-platform mobile apps and have the authors on-line!
See this thread and this one for details.
Win a copy of Machine Learning Systems: Designs that scale this week in the Scala forum
or Xamarin in Action: Creating native cross-platform mobile apps in the Android forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

tell me about BufferedReader  RSS feed

 
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the difference between following two statements?

BufferedReader bufReader = new BufferedReader(new java.io.FileReader(
file));

and

BufferedReader bufReader = new BufferedReader(new InputStreamReader(System.in));
 
Ranch Hand
Posts: 341
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Read the Sun's official description for BufferedReader, FileReader and InputStreamReader. Your doubt will be cleared.

Precisely, BufferedReader's constructor requires a Reader object. Now, in your case the FileReader is used for reading simple character files while InputStreamReader converts the byte input streams into characters.
 
Rancher
Posts: 42975
76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The obvious answer is that one reads from a file, while the other reads from a a stream. Since I'm sure you already know that, maybe you can elaborate a bit on the question.
 
You can't have everything. Where would you put it?
Rocket Oven Kickstarter - from the trailboss
https://coderanch.com/t/695773/Rocket-Oven-Kickstarter-trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!