Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The difference of `InputStream` `DataInputStream` and `BufferedInputStream` in java? [closed]

Tags:

The difference of InputStream DataInputStream and BufferedInputStream in java?

like image 777
alan.chen Avatar asked Mar 21 '12 13:03

alan.chen


People also ask

What is the difference between FileInputStream and BufferedInputStream?

A BufferedInputStream reads from another InputStream , but a FileInputStream reads from a file1.

What is the difference between DataInputStream and BufferedReader?

DataInputStream is a part of filtered streams, while BufferedReader is not. DataInputStream consumes less amount of memory space being it is a binary stream, whereas BufferedReader consumes more memory space being it is character stream.

What is the difference between BufferedReader and BufferedInputStream?

The main difference between BufferedReader and BufferedInputStream is that BufferedReader reads characters (text), whereas the BufferedInputStream reads raw bytes. The Java BufferedReader class is a subclass of the Java Reader class, so you can use a BufferedReader anywhere a Reader is required.

What is the difference between ByteArrayInputStream and BufferedInputStream?

The difference between ByteArrayInputStream and BufferedInputStream. The ByteArrayInputStream and BufferedInputStream are extended from InputStream class. A ByteArrayInputStream contains an internal buffer that contains bytes that may be read from the stream.


1 Answers

If the question is : "what the difference between those classes", here is a summary, but read the javadoc for more info :

An inputStream is the base class to read bytes from a stream (network or file). It provides the ability to read bytes from the stream and detect the end of the stream.

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. data is basicaly read ahead of time and this reduces disk or network access.

like image 162
Snicolas Avatar answered Oct 29 '22 15:10

Snicolas