FileInputStream Class
Package: java.io
The FileInputStream
class connects an input stream to an input file. You won’t often use this class to read directly from an input file. Instead, you’ll use it with other classes such as BufferedInputStream
and DataInputStream
.
Constructors
Constructor |
Description |
|
Creates a file input stream from the specified object. It throws |
|
Creates a file input stream from the specified pathname. It throws |
Creating a FileInputStream object
You can create FileInputStream
from a File
object like this:
File f;
FileInputStream fstream;
f = new File(“myfile.txt”);
fstream = new FileInputStream(f);
If you prefer, you can skip the File
object and create the FileInputStream
directly from a path string:
FileInputStream fstream;
fstream = new FileInputStream(“myfile.txt”);