7.4 The FileInputStream class 

Previous Index Next 


The FileInputStream class is used to retrieve the contents of a file. It's constructor accepts the name of a file to open as an argument. For instance:
FileInputStream input = new FileInputStream("test.txt");
Because the FileInputStream will read from the file a byte at a time it can be inefficient. To avoid this problem a BufferedInputStream is normally wrapped around the FileInputStream. For example:
BufferedInputStream input = new BufferedInputStream( new FileInputStream("test.txt") );



1