JAFS API v2

org.openafs.jafs
Class FileInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--org.openafs.jafs.FileInputStream

public class FileInputStream
extends InputStream

This class is a file input stream for files within AFS. It is an input stream for reading data from a File.

Version:
2.1, 08/03/2001
See Also:
File, FileOutputStream, FileInputStream

Constructor Summary
FileInputStream(File file)
          Creates a FileInputStream by opening a connection to an actual AFS file, the file represented by file file in the AFS file system.
FileInputStream(String name)
          Creates a FileInputStream by opening a connection to an actual AFS file, the file named by the path name name in the AFS file system.
 
Method Summary
 void close()
          Closes this file input stream and releases any system resources associated with the stream.
 int read()
          Reads the next 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.
 
Methods inherited from class java.io.InputStream
available, mark, markSupported, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileInputStream

public FileInputStream(String name)
                throws AFSFileException
Creates a FileInputStream by opening a connection to an actual AFS file, the file named by the path name name in the AFS file system.

Parameters:
name - the name of the file to read from
Throws:
AFSFileException - If an AFS specific error occurs, if the file does not, or cannot be opened for any other reason, including authorization.

FileInputStream

public FileInputStream(File file)
                throws AFSFileException
Creates a FileInputStream by opening a connection to an actual AFS file, the file represented by file file in the AFS file system.

Parameters:
file - an AFS file object representing a file to read from
Throws:
AFSFileException - If an AFS specific error occurs, if the file does not, or cannot be opened for any other reason, including authorization.
Method Detail

read

public int read()
         throws AFSFileException
Reads the next byte of data from this input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

This method simply performs in.read() and returns the result.

Specified by:
read in class InputStream
Returns:
the next byte of data, or -1 if the end of the stream is reached.
Throws:
AFSFileException - if an I/O or other file related error occurs.
See Also:
FileInputStream.read()

read

public int read(byte[] b)
         throws AFSFileException
Reads up to b.length bytes of data from this input stream into an array of bytes. This method blocks until some input is available.

Overrides:
read in class InputStream
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:
AFSFileException - if an I/O or other file related error occurs.

read

public int read(byte[] b,
                int off,
                int len)
         throws AFSFileException
Reads up to len bytes of data from this input stream into an array of bytes. This method blocks until some input is available.

Overrides:
read in class 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 -1 if there is no more data because the end of the file has been reached.
Throws:
AFSFileException - if an I/O or other file related error occurs.

skip

public long skip(long n)
          throws AFSFileException
Skips over and discards n bytes of data from the input stream. 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.

Overrides:
skip in class InputStream
Parameters:
n - the number of bytes to be skipped.
Returns:
the actual number of bytes skipped.
Throws:
AFSFileException - if an I/O or other file related error occurs.

close

public void close()
           throws AFSFileException
Closes this file input stream and releases any system resources associated with the stream.

Overrides:
close in class InputStream
Throws:
AFSFileException - if an I/O or other file related error occurs.

JAFS API v2