GeezerVison is showing docs.oracle.com — FileInputStream (Java Platform SE 8 )
Java™ Platform Standard Ed. 8
compact1, compact2, compact3
java.io
Class FileInputStream
-
-
Constructor Summary
Constructors
| Constructor |
Description |
FileInputStream(File file) |
Creates a FileInputStream by
opening a connection to an actual file,
the file named by the File
object file in the file system.
|
FileInputStream(FileDescriptor fdObj) |
Creates a FileInputStream by using the file descriptor
fdObj, which represents an existing connection to an
actual file in the file system.
|
FileInputStream(String name) |
Creates a FileInputStream by
opening a connection to an actual file,
the file named by the path name name
in the file system.
|
-
Method Summary
All Methods Instance Methods Concrete Methods
| Modifier and Type |
Method |
Description |
int |
available() |
Returns an estimate of the number of remaining bytes that can be read (or
skipped over) from this input stream without blocking by the next
invocation of a method for this input stream.
|
void |
close() |
Closes this file input stream and releases any system resources
associated with the stream.
|
protected void |
finalize() |
Ensures that the close method of this file input stream is
called when there are no more references to it.
|
FileChannel |
getChannel() |
Returns the unique FileChannel
object associated with this file input stream.
|
FileDescriptor |
getFD() |
Returns the FileDescriptor
object that represents the connection to
the actual file in the file system being
used by this FileInputStream.
|
int |
read() |
Reads a byte of data from this input stream.
|
int |
read(byte[] b) |
Reads up to b.length bytes of data from this input
stream into an array of bytes.
|
int |
read(byte[] b,
int off,
int len) |
Reads up to len bytes of data from this input stream
into an array of bytes.
|
long |
skip(long n) |
Skips over and discards n bytes of data from the
input stream.
|
-
-
Method Detail
-
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. If len is not zero, the method
blocks until some input is available; otherwise, no
bytes are read and 0 is returned.
- Overrides:
read in class InputStream
- Parameters:
b - the buffer into which the data is read.
off - the start offset in the destination array b
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:
NullPointerException - If b is null.
IndexOutOfBoundsException - If off is negative,
len is negative, or len is greater than
b.length - off
IOException - if an I/O error occurs.
- See Also:
InputStream.read()
Java™ Platform Standard Ed. 8
Submit a bug or feature For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples. Copyright © 1993, 2026, Oracle and/or its affiliates. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
|