当前页面:
在线文档首页 >
JDK 5 Documentation v1.1.8, Java 2 SDK 英文文档
Class java.io.FileInputStream - JDK 5 Documentation v1.1.8, Java 2 SDK 英文文档
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
A file input stream is an input stream for reading data from a
File
or from a
FileDescriptor
.
- See Also:
- File, FileDescriptor, FileOutputStream
-
FileInputStream(File)
- Creates an input file stream to read from the specified
File
object.
-
FileInputStream(FileDescriptor)
- Creates an input file stream to read from the specified file descriptor.
-
FileInputStream(String)
- Creates an input file stream to read from a file with the
specified name.
-
available()
- Returns the number of bytes that can be read from this file input
stream without blocking.
-
close()
- Closes this file input stream and releases any system resources
associated with the stream.
-
finalize()
- Ensures that the
close
method of this file input stream is
called when there are no more references to it.
-
getFD()
- Returns the opaque file descriptor object associated with this stream.
-
read()
- Reads a byte of data from this input stream.
-
read(byte[])
- Reads up to
b.length
bytes of data from this input
stream into an array of bytes.
-
read(byte[], int, int)
- Reads up to
len
bytes of data from this input stream
into an array of bytes.
-
skip(long)
- Skips over and discards
n
bytes of data from the
input stream.
FileInputStream
public FileInputStream(String name) throws FileNotFoundException
- Creates an input file stream to read from a file with the
specified name.
- Parameters:
- name - the system-dependent file name.
- Throws: FileNotFoundException
- if the file is not found.
- Throws: SecurityException
- if a security manager exists, its
checkRead
method is called with the name
argument to see if the application is allowed read access
to the file.
- See Also:
- checkRead
FileInputStream
public FileInputStream(File file) throws FileNotFoundException
- Creates an input file stream to read from the specified
File
object.
- Parameters:
- file - the file to be opened for reading.
- Throws: FileNotFoundException
- if the file is not found.
- Throws: SecurityException
- if a security manager exists, its
checkRead
method is called with the pathname
of this File
argument to see if the
application is allowed read access to the file.
- See Also:
- getPath, checkRead
FileInputStream
public FileInputStream(FileDescriptor fdObj)
- Creates an input file stream to read from the specified file descriptor.
- Parameters:
- fdObj - the file descriptor to be opened for reading.
- Throws: SecurityException
- if a security manager exists, its
checkRead
method is called with the file
descriptor to see if the application is allowed to read
from the specified file descriptor.
- See Also:
- checkRead
read
public native int read() throws IOException
- Reads a byte of data from this input stream. This method blocks
if no input is yet available.
- Returns:
- the next byte of data, or
-1
if the end of the
file is reached.
- Throws: IOException
- if an I/O error occurs.
- Overrides:
- read in class InputStream
read
public int read(byte b[]) throws IOException
- Reads up to
b.length
bytes of data from this input
stream 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 total number of bytes read into the buffer, or
-1
if there is no more data because the end of
the file has been reached.
- Throws: IOException
- if an I/O error occurs.
- Overrides:
- read in class InputStream
read
public int read(byte b[],
int off,
int len) throws IOException
- Reads up to
len
bytes of data from this input stream
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 total number of bytes read into the buffer, or
-1
if there is no more data because the end of
the file has been reached.
- Throws: IOException
- if an I/O error occurs.
- Overrides:
- read in class InputStream
skip
public native long skip(long n) throws IOException
- Skips over and discards
n
bytes of data from the
input stream. The skip
method may, for a variety of
reasons, end up skipping over some smaller number of bytes,
possibly 0
. The actual number of bytes skipped is returned.
- Parameters:
- n - the number of bytes to be skipped.
- Returns:
- the actual number of bytes skipped.
- Throws: IOException
- if an I/O error occurs.
- Overrides:
- skip in class InputStream
available
public native int available() throws IOException
- Returns the number of bytes that can be read from this file input
stream without blocking.
- Returns:
- the number of bytes that can be read from this file input
stream without blocking.
- Throws: IOException
- if an I/O error occurs.
- Overrides:
- available in class InputStream
close
public native void close() throws IOException
- Closes this file input stream and releases any system resources
associated with the stream.
- Throws: IOException
- if an I/O error occurs.
- 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 object associated with this stream.
- Throws: IOException
- if an I/O error occurs.
- See Also:
- FileDescriptor
finalize
protected void finalize() throws IOException
- Ensures that the
close
method of this file input stream is
called when there are no more references to it.
- Throws: IOException
- if an I/O error occurs.
- Overrides:
- finalize in class Object
- See Also:
- close
All Packages Class Hierarchy This Package Previous Next Index
Submit a bug or feature - Version 1.1.8 of Java Platform API Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries.
Copyright 1995-1999 Sun Microsystems, Inc. 901 San Antonio Road,
Palo Alto, California, 94303, U.S.A. All Rights Reserved.