Skip to Content
Java in a Nutshell, 5th Edition
book

Java in a Nutshell, 5th Edition

by David Flanagan
March 2005
Intermediate to advanced
1254 pages
104h 21m
English
O'Reilly Media, Inc.
Content preview from Java in a Nutshell, 5th Edition

Name

FileInputStream

Synopsis

This class is a subclass of InputStream that reads bytes from a file specified by name or by a File or FileDescriptor object. read( ) reads a byte or array of bytes from the file. It returns -1 when the end-of-file has been reached. To read binary data, you typically use this class in conjunction with a BufferedInputStream and DataInputStream. To read text, you typically use it with an InputStreamReader and BufferedReader. Call close( ) to close the file when input is no longer needed.

In Java 1.4 and later, use getChannel( ) to obtain a FileChannel object for reading from the underlying file using the New I/O API of java.nio and its subpackages.

java.io.FileInputStream

Figure 9-15. java.io.FileInputStream

public class FileInputStream extends InputStream {
// Public Constructors
     public FileInputStream(String name) throws FileNotFoundException;  
     public FileInputStream(File file) throws FileNotFoundException;  
     public FileInputStream(FileDescriptor fdObj);  
// Public Instance Methods
                  1.4  public java.nio.channels.FileChannel getChannel( );  
     public final FileDescriptor getFD( ) throws IOException;  
// Public Methods Overriding InputStream
     public int available( ) throws IOException;                          native
     public void close( ) throws IOException;  
     public int read( ) throws IOException;                               native
     public int read(byte[ ] b) throws IOException;  
     public int read(byte[ ] b, int off, int len) throws IOException; ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Java in a Nutshell, 8th Edition

Java in a Nutshell, 8th Edition

Benjamin J. Evans, Jason Clark, David Flanagan
Java in a Nutshell, 7th Edition

Java in a Nutshell, 7th Edition

Benjamin J. Evans, David Flanagan
Learning Java, 5th Edition

Learning Java, 5th Edition

Marc Loy, Patrick Niemeyer, Daniel Leuck
Learning Java, 4th Edition

Learning Java, 4th Edition

Patrick Niemeyer, Daniel Leuck

Publisher Resources

ISBN: 0596007736Supplemental ContentErrata Page