java.io
Class FileInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FileInputStream
-
- All Implemented Interfaces:
- Closeable, AutoCloseable
public class FileInputStream extends InputStream
AFileInputStream
obtains input bytes from a file in a file system. What files are available depends on the host environment.FileInputStream
is meant for reading streams of raw bytes such as image data. For reading streams of characters, consider usingFileReader
.- Since:
- JDK1.0
- See Also:
File
,FileDescriptor
,FileOutputStream
,Files.newInputStream(java.nio.file.Path, java.nio.file.OpenOption...)
-
-
Constructor Summary
Constructors Constructor and Description FileInputStream(File file)
Creates aFileInputStream
by opening a connection to an actual file, the file named by theFile
objectfile
in the file system.FileInputStream(FileDescriptor fdObj)
Creates aFileInputStream
by using the file descriptorfdObj
, which represents an existing connection to an actual file in the file system.FileInputStream(String name)
Creates aFileInputStream
by opening a connection to an actual file, the file named by the path namename
in the file system.
-
Method Summary
Methods Modifier and Type Method and 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 theclose
method of this file input stream is called when there are no more references to it.FileChannel
getChannel()
Returns the uniqueFileChannel
object associated with this file input stream.FileDescriptor
getFD()
Returns theFileDescriptor
object that represents the connection to the actual file in the file system being used by thisFileInputStream
.int
read()
Reads a byte of data from this input stream.int
read(byte[] b)
Reads up tob.length
bytes of data from this input stream into an array of bytes.int
read(byte[] b, int off, int len)
Reads up tolen
bytes of data from this input stream into an array of bytes.long
skip(long n)
Skips over and discardsn
bytes of data from the input stream.-
Methods inherited from class java.io.InputStream
mark, markSupported, reset
-
-
'Dev. 자바 > API 및 이론' 카테고리의 다른 글
[JAVA API] java.io.FileReader (0) | 2012.08.08 |
---|---|
[JAVA API] java.io.FileOutputStream (0) | 2012.08.08 |
[JAVA API] java.io.File (1) | 2012.08.08 |
[JAVA API] java.lang.Enum<E>, 열거형 (0) | 2012.08.08 |
[JAVA API] java.util.HashMap<K,V> (0) | 2012.08.07 |