Saturday, February 21, 2015

When to use a Buffered Reader and FileInputStream?

Basic questions hound me -
When should I use the buffered reader? When should I use FileInputStream? What are the advantages of each? How as a developer should I select? Which one is more efficient?

Some good websites that I have surfed have thrown light and one such is-
http://javarevisited.blogspot.in/2014/04/difference-between-fileinputstream-and-filereader-in-java.html

Another good explanation on Stackoverflow helps to clear the doubts even further-
http://stackoverflow.com/questions/10269862/java-reading-from-a-file-input-stream-vs-reader

A new concept, apart from Reader and InputStream proposed in the above blog needs to be explored further which is-
public final class Files extends Object
This class consists exclusively of static methods that operate on files, directories, or other types of files.
A detailed explanation follows on --http://docs.oracle.com/javase/7/docs/api/java/nio/file/Files.html

A detailed site on selection criterion is below for reference-
http://docs.oracle.com/javase/tutorial/essential/io/file.html 

No comments:

Post a Comment