Win a copy of Pragmatic AI this week in the Artificial Intelligence forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

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.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!