Difference between file and filereader




















BufferedReader Reader rd, int size — It creates a buffered character input stream that uses the specified size for an input buffer.

Figure 2: Program with BufferedReader. There is an object of type FileReader. That object is passed to BufferedReader. Finally, the programmer can close the BufferedReader and FileReader objects. BufferReader is a class that helps to read text from a character based input stream. Thus, this is the main difference between FileReader and BufferedReader.

Another difference between FileReader and BufferedReader is the buffering. That is; the FileReader is not buffered, but the BufferedReader is buffered. Furthermore, one other difference between FileReader and BufferedReader is that the read function in FileReader reads data from a file whereas the read method in BufferedReader uses a buffer to read data. Moreover, FileReader obtains characters from a file in the file system while BufferedReader enables another Reader to buffer the characters.

Speed is another difference between FileReader and BufferedReader. FileReader is slower than BufferedReader. Ask a Question. Please Sign up or sign in to vote. See more: Mobile. I am facing problem to use Filereader api in android. Posted Jan pm Muhamad Faizan Khan.

Updated Jan am Richard MacCutchan. Add a Solution. Accept Solution Reject Solution. Posted Jan am Richard MacCutchan. Add your solution here. OK Paste as. Treat my content as plain text, not as HTML. Existing Members Sign in to your account. This email is in use. Do you need your password? An interview is a place to write your best code.

This book, not only explains things well but also gives you lots of exercises to practice well. Here is a nice slide that explains the difference between FileReader and FileInputStream quite well:. It's better to use FileReader for reading text files because it will take care of converting bytes to characters but remember that FileReader uses the platform's default character encoding.

If you are reading a file that is encoded in a character encoding other than the host's default char encoding then you should use the InputStreamReader. Labels: core java , core java interview question answer , Java IO interview question , java io tutorial.

Unknown March 9, at PM. Sugandha September 10, at AM. Unknown August 1, at PM. Nagaraj March 5, at PM.

Newer Post Older Post Home. Subscribe to: Post Comments Atom.



0コメント

  • 1000 / 1000