The difference of InputStream
DataInputStream
and BufferedInputStream
in java?
A BufferedInputStream reads from another InputStream , but a FileInputStream reads from a file1.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With