com.sun.xfile
Class XFileInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--com.sun.xfile.XFileInputStream

public class XFileInputStream
extends java.io.InputStream

An XFile input stream is an input stream for reading data from an XFile.


Constructor Summary
XFileInputStream(java.lang.String name)
          Creates an input file stream to read from a file with the specified name.
XFileInputStream(XFile xfile)
          Creates an input file stream to read from the specified XFile object.
 
Method Summary
 int available()
          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 to b.length bytes of data from this file into an array of bytes.
 int read(byte[] b, int off, int len)
          Reads up to len bytes of data from this file into an array of bytes.
 long skip(long n)
          Skips over and discards n bytes of data from the file.
 
Methods inherited from class java.io.InputStream
mark, markSupported, reset
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

XFileInputStream

public XFileInputStream(XFile xfile)
                 throws java.io.IOException
Creates an input file stream to read from the specified XFile object.
Parameters:
xfile - the file to be opened for reading.
Throws:
java.io.FileNotFoundException - if the file is not found.

XFileInputStream

public XFileInputStream(java.lang.String name)
                 throws java.io.IOException
Creates 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.
Method Detail

read

public int read()
         throws java.io.IOException
Reads a byte of data from this XFile.
Returns:
the next byte of data, or -1 if the end of the file is reached.
Throws:
java.io.IOException - if an I/O error occurs.
Overrides:
read in class java.io.InputStream

read

public int read(byte[] b)
         throws java.io.IOException
Reads up to b.length bytes of data from this file into an array of bytes.
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:
java.io.IOException - if an I/O error occurs.
Overrides:
read in class java.io.InputStream

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Reads up to len bytes of data from this file into an array of bytes.
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:
java.io.IOException - if an I/O error occurs.
Overrides:
read in class java.io.InputStream

available

public int available()
              throws java.io.IOException
Returns the number of bytes yet to be read from this file.
Returns:
the number of bytes yet to be read from this file without blocking.
Throws:
java.io.IOException - if an I/O error occurs.
Overrides:
available in class java.io.InputStream

skip

public long skip(long n)
          throws java.io.IOException
Skips over and discards n bytes of data from the file. The skip method may, for a variety of reasons, end up skipping over some smaller number of bytes, possibly 0. The actual number of bytes skipped is returned.
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.
Overrides:
skip in class java.io.InputStream

close

public void close()
           throws java.io.IOException
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.
Throws:
java.io.IOException - if an I/O error occurs.
Overrides:
close in class java.io.InputStream