com.caucho.vfs
Class FileReadStream

java.lang.Object
  |
  +--com.caucho.vfs.StreamImpl
        |
        +--com.caucho.vfs.FileReadStream

public class FileReadStream
extends StreamImpl

Stream encapsulating FileInputStream


Fields inherited from class com.caucho.vfs.StreamImpl
nullPath, path
 
Constructor Summary
FileReadStream()
          Create a new FileReadStream.
FileReadStream(java.io.FileInputStream is)
          Create a new FileReadStream based on the java.io.* stream.
FileReadStream(java.io.FileInputStream is, Path path)
          Create a new FileReadStream based on the java.io.* stream.
 
Method Summary
 boolean canRead()
          Returns true if there's an associated file.
 boolean canSkip()
          Returns true if there's an associated file.
 void close()
          Closes the underlying stream.
 int getAvailable()
          Returns the number of bytes available for reading.
 void init(java.io.FileInputStream is)
          Initializes a VfsStream with an input/output stream pair.
 int read(byte[] buf, int offset, int length)
          Reads bytes from the file.
 long skip(long n)
          Skips bytes in the file.
 
Methods inherited from class com.caucho.vfs.StreamImpl
canWrite, clearWrite, flush, getAttribute, getAttributeNames, getFlushOnNewline, getNewline, getPath, getReadPosition, hasSkip, removeAttribute, setAttribute, setPath, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileReadStream

public FileReadStream()
Create a new FileReadStream.

FileReadStream

public FileReadStream(java.io.FileInputStream is)
Create a new FileReadStream based on the java.io.* stream.
Parameters:
is - the underlying input stream.

FileReadStream

public FileReadStream(java.io.FileInputStream is,
                      Path path)
Create a new FileReadStream based on the java.io.* stream.
Parameters:
is - the underlying input stream.
path - the associated Path.
Method Detail

init

public void init(java.io.FileInputStream is)
Initializes a VfsStream with an input/output stream pair. Before a read, the output will be flushed to avoid deadlocks.
Parameters:
is - the underlying InputStream.
os - the underlying OutputStream.

canSkip

public boolean canSkip()
Returns true if there's an associated file.

skip

public long skip(long n)
          throws java.io.IOException
Skips bytes in the file.
Overrides:
skip in class StreamImpl
Parameters:
n - the number of bytes to skip
Returns:
the actual bytes skipped.

canRead

public boolean canRead()
Returns true if there's an associated file.
Overrides:
canRead in class StreamImpl

read

public int read(byte[] buf,
                int offset,
                int length)
         throws java.io.IOException
Reads bytes from the file.
Overrides:
read in class StreamImpl
Parameters:
buf - a byte array receiving the data.
offset - starting index to receive data.
length - number of bytes to read.
Returns:
the number of bytes read or -1 on end of file.

getAvailable

public int getAvailable()
                 throws java.io.IOException
Returns the number of bytes available for reading.
Overrides:
getAvailable in class StreamImpl

close

public void close()
           throws java.io.IOException
Closes the underlying stream.
Overrides:
close in class StreamImpl