• Post Reply Bookmark Topic Watch Topic
  • New Topic

tell me about BufferedReader  RSS feed

 
Madhawi Maurya
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));
 
Anubhav Anand
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.
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!