com.karmasphere.share.util
Class OffsetInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.karmasphere.share.util.OffsetInputStream
All Implemented Interfaces:
Closeable

public class OffsetInputStream
extends FilterInputStream

A simple InputStream derivative, which keeps track of the current offset.


Field Summary
protected  long markOffset
          Marked offset
protected  long offset
          Current offset
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
OffsetInputStream(InputStream in)
          Create a new OffsetInputStream
OffsetInputStream(InputStream in, long offset)
          Create a new OffsetInputStream with a specified initial offset.
 
Method Summary
 long getOffset()
          Get the current offset
 void mark(int readLimit)
          Mark the stream.
 int read()
          Read a byte from the stream.
 int read(byte[] data)
          Read from the stream.
 int read(byte[] data, int offset, int length)
          Read from the stream.
 void reset()
          Reset the stream to the last mark;
 long skip(long n)
          Skip some bytes.
 
Methods inherited from class java.io.FilterInputStream
available, close, markSupported
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

offset

protected long offset
Current offset


markOffset

protected long markOffset
Marked offset

Constructor Detail

OffsetInputStream

public OffsetInputStream(InputStream in)
Create a new OffsetInputStream


OffsetInputStream

public OffsetInputStream(InputStream in,
                         long offset)
Create a new OffsetInputStream with a specified initial offset.

Method Detail

getOffset

public long getOffset()
Get the current offset


read

public int read()
         throws IOException
Read a byte from the stream.

Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] data)
         throws IOException
Read from the stream.

Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] data,
                int offset,
                int length)
         throws IOException
Read from the stream.

Overrides:
read in class FilterInputStream
Throws:
IOException

mark

public void mark(int readLimit)
Mark the stream.

Overrides:
mark in class FilterInputStream

reset

public void reset()
           throws IOException
Reset the stream to the last mark;

Overrides:
reset in class FilterInputStream
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Skip some bytes.

Overrides:
skip in class FilterInputStream
Throws:
IOException


Copyright © 2004-2005 Karamsphere. All Rights Reserved.