Package com.sun.xfile
Class XFileInputStream
java.lang.Object
java.io.InputStream
com.sun.xfile.XFileInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
An XFile input stream is an input stream for reading data from an
XFile
.-
Constructor Summary
ConstructorsConstructorDescriptionXFileInputStream
(XFile xfile) Creates an input file stream to read from the specifiedXFile
object.XFileInputStream
(String name) Creates an input file stream to read from a file with the specified name. -
Method Summary
Modifier and TypeMethodDescriptionint
Returns the number of bytes yet to be read from this file.void
close()
Closes this file input stream and releases any system resources associated with the stream.int
read()
Reads a byte of data from this XFile.int
read
(byte[] b) Reads up tob.length
bytes of data from this file into an array of bytes.int
read
(byte[] b, int off, int len) Reads up tolen
bytes of data from this file into an array of bytes.long
skip
(long n) Skips over and discardsn
bytes of data from the file.Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skipNBytes, transferTo
-
Constructor Details
-
XFileInputStream
Creates an input file stream to read from the specifiedXFile
object.- Parameters:
xfile
- the file to be opened for reading.- Throws:
FileNotFoundException
- if the file is not found.IOException
-
XFileInputStream
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.IOException
-
-
Method Details
-
read
Reads a byte of data from this XFile.- Specified by:
read
in classInputStream
- Returns:
- the next byte of data, or
-1
if the end of the file is reached. - Throws:
IOException
- if an I/O error occurs.
-
read
Reads up tob.length
bytes of data from this file into an array of bytes.- Overrides:
read
in classInputStream
- 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.
-
read
Reads up tolen
bytes of data from this file into an array of bytes.- Overrides:
read
in classInputStream
- 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.
-
available
Returns the number of bytes yet to be read from this file.- Overrides:
available
in classInputStream
- Returns:
- the number of bytes yet to be read from this file without blocking.
- Throws:
IOException
- if an I/O error occurs.
-
skip
Skips over and discardsn
bytes of data from the file. Theskip
method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly0
. The actual number of bytes skipped is returned.- Overrides:
skip
in classInputStream
- Parameters:
n
- the number of bytes to be skipped.- Returns:
- the actual number of bytes skipped.
- Throws:
IOException
- if an I/O error occurs.
-
close
Closes this file input stream and releases any system resources associated with the stream. After the file is closed further I/O operations may throw IOException.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
- if an I/O error occurs.
-