Win a copy of Get Programming with Java (MEAP only) this week in the Beginning Java 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

What's the diff between these?  RSS feed

 
Sheriff
Posts: 9094
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
BufferedReader br = new BufferedReader( new InputStreamReader( new FileInputStream( "text.txt" ) ) );

BufferedReader in = new BufferedReader( new FileReader( "text.txt" ) );

Are they equivalent? How are they different?
 
Ranch Hand
Posts: 396
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Marilyn,
I'm just a beginer in I/O. so i may not be correct. but what i feel is that we'll use first format when our file text.txt is having binary data ( non unicode ).
while second format will be used if text.txt is having data in unicode .
would request others to correct me.
regards
Deekasha
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Marylin,
Actually FileReader extends InputStreamReader and doesn't add any additional fields or methods so, the only real difference is FileReader allows an easier to read implementation.
Hope this helps
 
Let's get him boys! We'll make him read this tiny ad!
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!