Win a copy of Bad Programming Practices 101 (e-book) this week in the Beginning Java forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

What's the diff between these?  RSS feed

 
Sheriff
Posts: 9087
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
 
We cannot change unless we survive, but we will not survive unless we change. Evolving tiny ad:
Why should you try IntelliJ IDEA ?
https://coderanch.com/wiki/696337/IntelliJ-IDEA
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!