com.caucho.vfs
Class SpyRandomAccessStream

java.lang.Object
  extended by com.caucho.vfs.RandomAccessStream
      extended by com.caucho.vfs.SpyRandomAccessStream
All Implemented Interfaces:
LockableStream

public class SpyRandomAccessStream
extends RandomAccessStream

Reads from a file in a random-access fashion.


Constructor Summary
SpyRandomAccessStream(RandomAccessStream file)
           
 
Method Summary
 void closeImpl()
          Closes the stream.
 long getFilePointer()
          Returns the current position of the file pointer.
 java.io.InputStream getInputStream()
          Returns an InputStream for this stream.
 long getLength()
          Returns the length.
 java.io.OutputStream getOutputStream()
          Returns an OutputStream for this stream.
 int read()
          Read a byte from the file, advancing the pointer.
 int read(byte[] buffer, int offset, int length)
          Reads a block from a given location.
 int read(char[] buffer, int offset, int length)
          Reads a block from a given location.
 int read(long fileOffset, byte[] buffer, int offset, int length)
          Reads a block from a given location.
 boolean seek(long position)
          Seeks to the given position in the file.
 void write(byte[] buffer, int offset, int length)
          Writes a block starting from the current file pointer.
 void write(int b)
          Write a byte to the file, advancing the pointer.
 void write(long fileOffset, byte[] buffer, int offset, int length)
          Writes a block from a given location.
 
Methods inherited from class com.caucho.vfs.RandomAccessStream
allocate, close, free, getUseCount, isOpen, lock, unlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SpyRandomAccessStream

public SpyRandomAccessStream(RandomAccessStream file)
Method Detail

getLength

public long getLength()
               throws java.io.IOException
Returns the length.

Specified by:
getLength in class RandomAccessStream
Throws:
java.io.IOException

read

public int read(byte[] buffer,
                int offset,
                int length)
         throws java.io.IOException
Reads a block from a given location.

Specified by:
read in class RandomAccessStream
Throws:
java.io.IOException

read

public int read(char[] buffer,
                int offset,
                int length)
         throws java.io.IOException
Reads a block from a given location.

Specified by:
read in class RandomAccessStream
Throws:
java.io.IOException

read

public int read(long fileOffset,
                byte[] buffer,
                int offset,
                int length)
         throws java.io.IOException
Reads a block from a given location.

Specified by:
read in class RandomAccessStream
Throws:
java.io.IOException

write

public void write(byte[] buffer,
                  int offset,
                  int length)
           throws java.io.IOException
Description copied from class: RandomAccessStream
Writes a block starting from the current file pointer.

Specified by:
write in class RandomAccessStream
Throws:
java.io.IOException

write

public void write(long fileOffset,
                  byte[] buffer,
                  int offset,
                  int length)
           throws java.io.IOException
Writes a block from a given location.

Specified by:
write in class RandomAccessStream
Throws:
java.io.IOException

seek

public boolean seek(long position)
Seeks to the given position in the file.

Specified by:
seek in class RandomAccessStream

getOutputStream

public java.io.OutputStream getOutputStream()
                                     throws java.io.IOException
Returns an OutputStream for this stream.

Specified by:
getOutputStream in class RandomAccessStream
Throws:
java.io.IOException

getInputStream

public java.io.InputStream getInputStream()
                                   throws java.io.IOException
Returns an InputStream for this stream.

Specified by:
getInputStream in class RandomAccessStream
Throws:
java.io.IOException

read

public int read()
         throws java.io.IOException
Read a byte from the file, advancing the pointer.

Specified by:
read in class RandomAccessStream
Throws:
java.io.IOException

write

public void write(int b)
           throws java.io.IOException
Write a byte to the file, advancing the pointer.

Specified by:
write in class RandomAccessStream
Throws:
java.io.IOException

getFilePointer

public long getFilePointer()
                    throws java.io.IOException
Returns the current position of the file pointer.

Specified by:
getFilePointer in class RandomAccessStream
Throws:
java.io.IOException

closeImpl

public void closeImpl()
               throws java.io.IOException
Closes the stream.

Overrides:
closeImpl in class RandomAccessStream
Throws:
java.io.IOException