Text and Binary Files
Binary files
Connect a binary input stream to a file
A subset of the InputStream hierarchy
InputStream {abstract}
FileInputStream
FilterInputStream
BufferedInputStream
DataInputStream {implements DataInput interface}
Notes
- All classes in the java.io and java.util.zip packages that end with InputStream are members of the InputStream hierarchy.
- The FilterInputStream class is a superclass of all classes that filter binary input streams.
Classes used to connect a binary input stream to a file
DataInputStream reads data from the stream ->BufferedInputStream creates a buffer for the stream ->FileInputStream connects the stream to the file
Constructors of these classes
| Constructor | Throws |
|---|---|
| DataInputStream(InputStream) | None |
| BufferedInputStream(InputStream) | None |
| FileInputStream(File) | FileNotFoundException |
| FileInputStream(StringFileName) | FileNotFoundException |
How to connect a binary input stream to a file
DataInputStream in = new DataInputStream(
new BufferedInputStream(
new FileInputStream(productsFile)));