Class java.io.FileInputStream
All Packages Class Hierarchy This Package Previous Next Index
Class java.io.FileInputStream
java.lang.Object
|
+----java.io.InputStream
|
+----java.io.FileInputStream
- public class FileInputStream
- extends InputStream
File input stream, can be constructed from
a file descriptor or a file name. - See Also:
- FileOutputStream, File
- FileInputStream(File)
- Creates an input file from the specified File object.
- FileInputStream(FileDescriptor)
- FileInputStream(String)
- Creates an input file with the specified system dependent file name.
- available()
- Returns the number of bytes that can be read
without blocking.
- close()
- Closes the input stream.
- finalize()
- Closes the stream when garbage is collected.
- getFD()
- Returns the opaque file descriptor object associated with this stream.
- read()
- Reads a byte of data.
- read(byte[])
- Reads data into an array of bytes.
- read(byte[], int, int)
- Reads data into an array of bytes.
- skip(long)
- Skips n bytes of input.
FileInputStream
public FileInputStream(String name) throws FileNotFoundException
- Creates an input file with the specified system dependent file name.
- Parameters:
- name - the system dependent file name
- Throws: IOException
- If the file is not found.
FileInputStream
public FileInputStream(File file) throws FileNotFoundException
- Creates an input file from the specified File object.
- Parameters:
- file - the file to be opened for reading
- Throws: IOException
- If the file is not found.
FileInputStream
public FileInputStream(FileDescriptor fdObj)
read
public int read() throws IOException
- Reads a byte of data. This method will block if no input is available.
- Returns:
- the byte read, or -1 if the end of the stream is reached.
- Throws: IOException
- If an I/O error has occurred.
- Overrides:
- read in class InputStream
read
public int read(byte b[]) throws IOException
- Reads data into an array of bytes.
This method blocks until some input is available.
- Parameters:
- b - the buffer into which the data is read
- Returns:
- the actual number of bytes read. -1 is returned if the end of stream is reached.
- Throws: IOException
- If an I/O error has occurred.
- Overrides:
- read in class InputStream
read
public int read(byte b[],
int off,
int len) throws IOException
- Reads data into an array of bytes.
This method blocks until some input is available.
- Parameters:
- b - the buffer into which the data is read
- off - the start offset of the data
- len - the maximum number of bytes read
- Returns:
- the actual number of bytes read. -1 is returned when the end of the stream is reached.
- Throws: IOException
- If an I/O error has occurred.
- Overrides:
- read in class InputStream
skip
public long skip(long n) throws IOException
- Skips n bytes of input.
- Parameters:
- n - the number of bytes to be skipped
- Returns:
- the actual number of bytes skipped.
- Throws: IOException
- If an I/O error has occurred.
- Overrides:
- skip in class InputStream
available
public int available() throws IOException
- Returns the number of bytes that can be read
without blocking.
- Returns:
- the number of available bytes, which is initially equal to the file size.
- Overrides:
- available in class InputStream
close
public void close() throws IOException
- Closes the input stream. This method must be called
to release any resources associated with
the stream.
- Throws: IOException
- If an I/O error has occurred.
- Overrides:
- close in class InputStream
getFD
public final FileDescriptor getFD() throws IOException
- Returns the opaque file descriptor object associated with this stream.
- Returns:
- the file descriptor.
finalize
protected void finalize() throws IOException
- Closes the stream when garbage is collected.
- Overrides:
- finalize in class Object
All Packages Class Hierarchy This Package Previous Next Index