org.abstracthorizon.mercury.common.io
Class RangedInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.abstracthorizon.mercury.common.io.RangedInputStream
All Implemented Interfaces:
Closeable

public class RangedInputStream
extends InputStream

Input stream that returns only a defined range

Author:
Daniel Sendula

Field Summary
protected  long from
          Starting offset
protected  InputStream is
          Underlying input stream
protected  long left
          Number of bytes left to be read
protected  long marked
          Mark
protected  long readlimit
          Read limit
protected  long readlimitCache
          Read limit cache
protected  long to
          End offset
 
Constructor Summary
RangedInputStream(InputStream is, long from, long to)
          Constructor
 
Method Summary
 int available()
           
 void close()
           
 void mark(int readlimit)
           
 boolean markSupported()
           
 int read()
           
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
 void reset()
           
 long skip(long n)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

is

protected InputStream is
Underlying input stream


from

protected long from
Starting offset


to

protected long to
End offset


left

protected long left
Number of bytes left to be read


marked

protected long marked
Mark


readlimit

protected long readlimit
Read limit


readlimitCache

protected long readlimitCache
Read limit cache

Constructor Detail

RangedInputStream

public RangedInputStream(InputStream is,
                         long from,
                         long to)
                  throws IOException
Constructor

Parameters:
is - input stream
from - from offset
to - to offset
Throws:
IOException
Method Detail

available

public int available()
              throws IOException
Overrides:
available in class InputStream
Throws:
IOException

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class InputStream
Throws:
IOException

mark

public void mark(int readlimit)
Overrides:
mark in class InputStream

markSupported

public boolean markSupported()
Overrides:
markSupported in class InputStream

read

public int read()
         throws IOException
Specified by:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Overrides:
read in class InputStream
Throws:
IOException

reset

public void reset()
           throws IOException
Overrides:
reset in class InputStream
Throws:
IOException

skip

public long skip(long n)
          throws IOException
Overrides:
skip in class InputStream
Throws:
IOException


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.