edu.harvard.hul.ois.jhove
Class CountedInputStream
java.lang.Object
   java.io.InputStream
java.io.InputStream
       java.io.FilterInputStream
java.io.FilterInputStream
           edu.harvard.hul.ois.jhove.CountedInputStream
edu.harvard.hul.ois.jhove.CountedInputStream
- All Implemented Interfaces: 
- java.io.Closeable
- public class CountedInputStream 
- extends java.io.FilterInputStream
A FilterInputStream which passes only a specified
 number of bytes, then returns an EOF condition.
- Author:
- Gary McGath
 
| Fields inherited from class java.io.FilterInputStream | 
| in | 
 
 
| Method Summary | 
|  int | read()Reads a single byte from the stream and decrements
  the count of remaining bytes.
 | 
|  int | read(byte[] b)Reads some number of bytes from the input stream and
 stores them into the buffer array b.
 | 
|  int | read(byte[] b,
     int off,
     int len)Reads up to len bytes of data from the input stream 
 into an array of bytes.
 | 
|  long | skip(long n)Skips n bytes.
 | 
 
| Methods inherited from class java.io.FilterInputStream | 
| available, close, mark, markSupported, reset | 
 
| Methods inherited from class java.lang.Object | 
| clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
 
CountedInputStream
public CountedInputStream(java.io.InputStream instrm,
                          int count)
- Parameters:
- instrm- The InputStream being counted
- count- The number of bytes to be allowed
read
public int read()
         throws java.io.IOException
- Reads a single byte from the stream and decrements
  the count of remaining bytes.  If the count
  is exhausted, returns -1 to signify end of file.
 
- 
- Overrides:
- readin class- java.io.FilterInputStream
 
- 
- Throws:
- java.io.IOException
 
read
public int read(byte[] b)
         throws java.io.IOException
- Reads some number of bytes from the input stream and
 stores them into the buffer array b. The number of
 bytes actually read is returned as an integer.
 
 The number of bytes read will not exceed the number
 of bytes remaining in the count.  The count is
 decremented by the number of bytes actually read.
 
- 
- Overrides:
- readin class- java.io.FilterInputStream
 
- 
- Throws:
- java.io.IOException
 
read
public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
- Reads up to len bytes of data from the input stream 
 into an array of bytes. An attempt is made to read as 
 many as len bytes, but a smaller number may be read, 
 possibly zero. The number of bytes actually read is
 returned as an integer.
 
 The number of bytes read will not exceed the number
 of bytes remaining in the count.  The count is
 decremented by the number of bytes actually read.
 
- 
- Overrides:
- readin class- java.io.FilterInputStream
 
- 
- Throws:
- java.io.IOException
 
skip
public long skip(long n)
          throws java.io.IOException
- Skips n bytes.
  Decrements the count by the number of bytes
  actually skipped.
 
- 
- Overrides:
- skipin class- java.io.FilterInputStream
 
- 
- Throws:
- java.io.IOException