• Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between FileInputstream and FileReader  RSS feed

 
krishnadhar Mellacheruvu
Ranch Hand
Posts: 118
Android Java Objective C
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
example1




example2



Now reader reads txt files and Input-stream reads Binary data. Is this the only difference present or is there any other view in the difference aspect.


 
Winston Gutkowski
Bartender
Posts: 10573
65
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
krishnadhar Mellacheruvu wrote:Now reader reads txt files and Input-stream reads Binary data.

A slight oversimplification; but it's certainly true that you should normally use a Reader (of which FileReader is but one subtype) to read text data.

Is this the only difference present or is there any other view in the difference aspect.

Well, FileInputStream is part of a hierarchy starting from InputStream, and is usually used to apply it to a File; however, Java 1.7 introduced a whole new set of classes in the java.nio.file package - in particular, Path and Files - which are worth getting to know, as they can simplify a lot of the things you want to do with files.

HIH

Winston
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!