The
FilterInputStream class accomplishes two things that are completely different. Where DataInputStream allows us to read different basic types of data and string objects (all methods begin with "read", such as ReadByte (), readfloat (), etc.). Along with the corresponding DataOutputStream, we can move the basic type of data from one place to another through the data "stream". These "places" are determined by the categories summarized in table 10.1. If you read the data in the block and parse it yourself, you don't need to use DataInputStream. But in many other cases, we generally want to use it to automatically format the data we read. The remaining classes of
are used to modify the internal behavior of the InputStream: whether to buffer, whether to track the rows of data they read, and whether to push back a character, and so on. The latter two types look particularly like providing support for building a compiler (in other words, adding them to support the Java compiler's build), so they are generally not used in conventional programming. The
probably buffers its input almost every time, regardless of which IO device is connected. So the best thing about IO library is to treat the buffered input as a special case, while the buffer input is accepted as a standard practice.
Table 10.3 filterinputstream type
Class
|
Function
|
Constructor Arguments
|
How to use it
|
Data-inputstream
|
Used in concert and DataOutputStream, so can read primitives (int, char, long, etc.) from a stream in a port Able fashion.
|
InputStream
|
Contains a full interface to allow your to read primitive types.
|
Buffered-inputstream
|
Use the to prevent a physical read every for more data in want. "Re saying" use a buffer.
|
InputStream, with optional buffer size.
|
This doesn ' t provide the interface per se, just a requirement that a buffer is used. Attach an interface object.
|
Linenumber-inputstream
|
Keeps track of line numbers in the input stream; Can call Getlinenumber () and setlinenumber (int).
|
InputStream
|
This is just adds line numbering and so you'll probably attach a interface object.
|
Pushback-inputstream
|
Has a one byte push-back buffer so, can push back to the last character read.
|
InputStream
|
Generally used in the scanner for a compiler and probably included because the Java compiler needed it. You are probably won ' t use this.
|
Class feature builder parameters/how to use
DataInputStream is used in conjunction with DataOutputStream to enable it to read the basic data type (Int,char,long, etc.) in a stream in a mobile way inputstream/contains a complete interface for reading basic data types
Bufferedinputstream avoids having to physically read every time you want more data, telling it to "look in the buffer first" inputstream, there is no optional buffer size/It does not provide an interface, it simply emits a requirement to use a buffer. Require the same interface object to be connected together
Linenumberinputstream trace the line number in the input stream; callable Getlinenumber () and setlinenumber (int) Simply add the ability to number the data row, so you may need to connect to the same real interface object
Pushbackinputstream has a byte push buffer so that the last character inputstream/read in is usually used by the compiler in the scanner because the Java compiler needs it. Typically not used in your own code.