com.adobe.acrobat.bytearray
Class ByteRangeInputStream

java.lang.Object
  |
  +--java.io.InputStream
        |
        +--com.adobe.acrobat.bytearray.ByteRangeInputStream

public class ByteRangeInputStream
extends java.io.InputStream

InputStream subclass that, given a ContiguousByteRange and an InputStream, streams only those bytes from the given InputStream whose offsets are delimited by the ContiguousByteRange.

Version:
1.0 9 April 1997 Copyright (c) 1997, Adobe Systems Inc., All Rights Reserved.

Constructor Summary
ByteRangeInputStream(java.io.InputStream stm, ContiguousByteRange br)
          Create a new ByteRangeInputStream which provides only the bytes from the given InputStream at offsets contained in the given ContiguousByteRange.

 

Method Summary
 int available()
          Return the number of bytes available on this ByteRangeInputStream for the next read to return without blocking.
 void mark(int readlimit)
          Mark the current position in this ByteRangeInputStream
 boolean markSupported()
          Return whether or not marking is supported on this ByteRangeInputStream.
 int read()
          Read the next byte in the substream whose offset appears in this ByteRangeInputStream's associated ContiguousByteRange.
 int read(byte[] b, int off, int len)
          Read the next len bytes into the byte-buffer b starting at b[off] and return the number of bytes actually read.
 void reset()
          Reset this ByteRangeInputStream back to wherever it was the last time mark was called.
 long skip(long n)
          Skip at most n bytes in this ByteRangeInputStream.

 

Methods inherited from class java.io.InputStream
close, read

 

Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

 

Constructor Detail

ByteRangeInputStream

public ByteRangeInputStream(java.io.InputStream stm,
                            ContiguousByteRange br)
Create a new ByteRangeInputStream which provides only the bytes from the given InputStream at offsets contained in the given ContiguousByteRange.
Parameters:
stm - the InputStream, a subset of whose bytes will be provided by this ByteRangeInputStream
br - the ContiguousByteRange enumerating which bytes are to be read and which are to be skipped
Method Detail

available

public int available()
              throws java.io.IOException
Return the number of bytes available on this ByteRangeInputStream for the next read to return without blocking.
Returns:
the number of available bytes
Throws:
java.io.IOException - Arbitrary IOExceptions may be thrown
Overrides:
available in class java.io.InputStream

mark

public void mark(int readlimit)
Mark the current position in this ByteRangeInputStream
Parameters:
readLimit - the maximum number of bytes that will be read before the next reset
Overrides:
mark in class java.io.InputStream
See Also:
reset, markSupported

markSupported

public boolean markSupported()
Return whether or not marking is supported on this ByteRangeInputStream. If the sub-InputStream from which this ByteRangeInputStream reads its bytes supports marking, so does this ByteRangeInputStream.
Returns:
true if mark is supported
Overrides:
markSupported in class java.io.InputStream
See Also:
mark, reset

read

public int read()
         throws java.io.IOException
Read the next byte in the substream whose offset appears in this ByteRangeInputStream's associated ContiguousByteRange.
Returns:
the next byte in this stream, or -1 if at EOF
Throws:
java.io.IOException - arbitrary IOExceptions may be thrown
Overrides:
read in class java.io.InputStream

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Read the next len bytes into the byte-buffer b starting at b[off] and return the number of bytes actually read.
Parameters:
b - the buffer into which to read the bytes
off - the offset in b at which to start writing the bytes
len - the maximum number of bytes to write
Returns:
the actual number of bytes written, or -1 if at EOF
Throws:
java.io.IOException - arbitrary IOExceptions may be thrown
Overrides:
read in class java.io.InputStream

reset

public void reset()
           throws java.io.IOException
Reset this ByteRangeInputStream back to wherever it was the last time mark was called.
Throws:
java.io.IOException - arbitrary IOExceptions may be thrown
Overrides:
reset in class java.io.InputStream
See Also:
mark, markSupported

skip

public long skip(long n)
          throws java.io.IOException
Skip at most n bytes in this ByteRangeInputStream.
Parameters:
n - the number of bytes to skip
Returns:
the number of bytes that were actually skipped
Throws:
java.io.IOException - arbitrary IOExceptions may be thrown
Overrides:
skip in class java.io.InputStream