Package com.sun.xfile
Class XFileInputStream
- java.lang.Object
-
- java.io.InputStream
-
- com.sun.xfile.XFileInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable
public class XFileInputStream extends java.io.InputStreamAn XFile input stream is an input stream for reading data from anXFile.
-
-
Constructor Summary
Constructors Constructor Description XFileInputStream(XFile xfile)Creates an input file stream to read from the specifiedXFileobject.XFileInputStream(java.lang.String name)Creates an input file stream to read from a file with the specified name.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()Returns the number of bytes yet to be read from this file.voidclose()Closes this file input stream and releases any system resources associated with the stream.intread()Reads a byte of data from this XFile.intread(byte[] b)Reads up tob.lengthbytes of data from this file into an array of bytes.intread(byte[] b, int off, int len)Reads up tolenbytes of data from this file into an array of bytes.longskip(long n)Skips over and discardsnbytes of data from the file.
-
-
-
Constructor Detail
-
XFileInputStream
public XFileInputStream(XFile xfile) throws java.io.IOException
Creates an input file stream to read from the specifiedXFileobject.- Parameters:
xfile- the file to be opened for reading.- Throws:
java.io.FileNotFoundException- if the file is not found.java.io.IOException
-
XFileInputStream
public XFileInputStream(java.lang.String name) throws java.io.IOExceptionCreates an input file stream to read from a file with the specified name.- Parameters:
name- the system-dependent file name.- Throws:
java.io.FileNotFoundException- if the file is not found.java.io.IOException
-
-
Method Detail
-
read
public int read() throws java.io.IOExceptionReads a byte of data from this XFile.- Specified by:
readin classjava.io.InputStream- Returns:
- the next byte of data, or
-1if the end of the file is reached. - Throws:
java.io.IOException- if an I/O error occurs.
-
read
public int read(byte[] b) throws java.io.IOExceptionReads up tob.lengthbytes of data from this file into an array of bytes.- Overrides:
readin classjava.io.InputStream- Parameters:
b- the buffer into which the data is read.- Returns:
- the total number of bytes read into the buffer, or
-1if there is no more data because the end of the file has been reached. - Throws:
java.io.IOException- if an I/O error occurs.
-
read
public int read(byte[] b, int off, int len) throws java.io.IOExceptionReads up tolenbytes of data from this file into an array of bytes.- Overrides:
readin classjava.io.InputStream- 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
-1if there is no more data because the end of the file has been reached. - Throws:
java.io.IOException- if an I/O error occurs.
-
available
public int available() throws java.io.IOExceptionReturns the number of bytes yet to be read from this file.- Overrides:
availablein classjava.io.InputStream- Returns:
- the number of bytes yet to be read from this file without blocking.
- Throws:
java.io.IOException- if an I/O error occurs.
-
skip
public long skip(long n) throws java.io.IOExceptionSkips over and discardsnbytes of data from the file. Theskipmethod 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:
skipin classjava.io.InputStream- Parameters:
n- the number of bytes to be skipped.- Returns:
- the actual number of bytes skipped.
- Throws:
java.io.IOException- if an I/O error occurs.
-
close
public void close() throws java.io.IOExceptionCloses 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:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.InputStream- Throws:
java.io.IOException- if an I/O error occurs.
-
-