|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.io.InputStream
java.io.FileInputStream
public class FileInputStream
FileInputStream is a class for reading bytes from a file. This class may also be used with other InputStreams, ie: BufferedInputStream, to read data from a file with buffering.
FileOutputStream| Field Summary | |
|---|---|
(package private) FileDescriptor |
fd
The FileDescriptor representing this FileInputStream. |
(package private) boolean |
innerFD
|
| Constructor Summary | |
|---|---|
FileInputStream(File file)
Constructs a new FileInputStream on the File file. |
|
FileInputStream(FileDescriptor fd)
Constructs a new FileInputStream on the FileDescriptor fd. |
|
FileInputStream(String fileName)
Constructs a new FileInputStream on the file named fileName. |
|
| Method Summary | |
|---|---|
int |
available()
Returns a int representing then number of bytes that are available before this InputStream will block. |
void |
close()
Close the FileInputStream. |
protected void |
finalize()
This method ensures that all resources for this file are released when it is about to be garbage collected. |
FileChannel |
getChannel()
Returns the FileChannel equivalent to this input stream. |
FileDescriptor |
getFD()
Returns the FileDescriptor representing the operating system resource for this FileInputStream. |
int |
read()
Reads a single byte from this FileInputStream and returns the result as an int. |
int |
read(byte[] buffer)
Reads bytes from the FileInputStream and stores them in byte array buffer. |
int |
read(byte[] buffer,
int offset,
int count)
Reads at most count bytes from the FileInputStream and
stores them in byte array buffer starting at
offset. |
long |
skip(long count)
Skips count number of bytes in this FileInputStream. |
| Methods inherited from class java.io.InputStream |
|---|
mark, markSupported, reset |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
FileDescriptor fd
boolean innerFD
| Constructor Detail |
|---|
public FileInputStream(File file)
throws FileNotFoundException
file. If the
file does not exist, the FileNotFoundException is thrown.
file - the File on which to stream reads.
FileNotFoundException - If the file is not found.SecurityManager.checkRead(FileDescriptor),
SecurityManager.checkRead(String),
SecurityManager.checkRead(String, Object)public FileInputStream(FileDescriptor fd)
fd.
The file must already be open, therefore no
FileNotFoundException will be thrown.
fd - the FileDescriptor on which to stream reads.SecurityManager.checkRead(FileDescriptor),
SecurityManager.checkRead(String),
SecurityManager.checkRead(String, Object)
public FileInputStream(String fileName)
throws FileNotFoundException
fileName.
If the file does not exist, the FileNotFoundException is
thrown. The fileName may be absolute or relative to the
System property "user.dir".
fileName - the file on which to stream reads.
FileNotFoundException - If the fileName is not found.| Method Detail |
|---|
public int available()
throws IOException
available in class InputStreamIOException - If an error occurs in this stream.
public void close()
throws IOException
close in interface Closeableclose in class InputStreamIOException - If an error occurs attempting to close this FileInputStream.
protected void finalize()
throws IOException
finalize in class ObjectIOException - If an error occurs attempting to finalize this
FileInputStream.public FileChannel getChannel()
The file channel is read-only and has an initial position within the file that is the same as the current position of the FileInputStream within the file. All changes made to the underlying file descriptor state via the channel are visible by the input stream and vice versa.
public final FileDescriptor getFD()
throws IOException
IOException - If an error occurs attempting to get the FileDescriptor of
this FileInputStream.
public int read()
throws IOException
read in class InputStreamIOException - If the stream is already closed or another IOException
occurs.
public int read(byte[] buffer)
throws IOException
buffer. Answer the number of bytes actually read or -1 if
no bytes were read and end of stream was encountered.
read in class InputStreambuffer - the byte array in which to store the read bytes.
IOException - If the stream is already closed or another IOException
occurs.
public int read(byte[] buffer,
int offset,
int count)
throws IOException
count bytes from the FileInputStream and
stores them in byte array buffer starting at
offset. Answer the number of bytes actually read or -1 if
no bytes were read and end of stream was encountered.
read in class InputStreambuffer - the byte array in which to store the read bytes.offset - the offset in buffer to store the read bytes.count - the maximum number of bytes to store in buffer.
IOException - If the stream is already closed or another IOException
occurs.
public long skip(long count)
throws IOException
count number of bytes in this FileInputStream.
Subsequent read()'s will not return these bytes unless
reset() is used. This method may perform multiple reads to
read count bytes.
skip in class InputStreamcount - the number of bytes to skip.
IOException - If the stream is already closed or another IOException
occurs.
|
Build 1.0_r1(from source) | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||