Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between BufferedReader and BufferedInputStream

What are the differences between BufferedReader , BufferedInputStream and Scanner in java? BufferedReader reads the text and BufferedInputStream reads byte. Is there any difference other than this?

like image 612
user1357722 Avatar asked May 03 '12 15:05

user1357722


People also ask

What is difference between BufferedReader and InputStreamReader?

BufferedReader reads a couple of characters from the Input Stream and stores them in a buffer. InputStreamReader reads only one character from the input stream and the remaining characters still remain in the streams hence There is no buffer in this case.

What is the difference between InputStream and BufferedInputStream?

DataInputStream is a kind of InputStream to read data directly as primitive data types. BufferedInputStream is a kind of inputStream that reads data from a stream and uses a buffer to optimize speed access to data.

What is difference between BufferedReader and FileReader?

FileReader is used to read a file from a disk drive whereas BufferedReader is not bound to only reading files. It can be used to read data from any character stream.

What is the purpose of BufferedInputStream?

A BufferedInputStream adds functionality to another input stream-namely, the ability to buffer the input and to support the mark and reset methods. When the BufferedInputStream is created, an internal buffer array is created.


1 Answers

I guess, the difference is the same as between reader and inputstream: one is character-based, another is byte-based. For example, reader normally supports encoding...

Edit: Check this question: The difference between InputStream and InputStreamReader when reading multi-byte characters

like image 197
Igor Deruga Avatar answered Sep 20 '22 18:09

Igor Deruga