org.entityfs.support.io
Class CountingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by org.entityfs.support.io.InputStreamProxy
          extended by org.entityfs.support.io.CountingInputStream
All Implemented Interfaces:
Closeable

public class CountingInputStream
extends InputStreamProxy

This InputStream counts how many bytes that the client has read from it. The number of bytes skipped are also added to the total.

Since:
1.1
Author:
Karl Gustafsson
See Also:
CountingOutputStream

Constructor Summary
CountingInputStream(InputStream wrapped)
          Create a counting input stream that counts how many bytes that are read from the wrapped stream.
 
Method Summary
 long getNoOfBytesReadOrSkipped()
          Get the number of bytes that the client has read from or skipped over in this stream.
 void mark(int readlimit)
          This method does nothing.
 boolean markSupported()
           
 int read()
           
 int read(byte[] barr)
           
 int read(byte[] barr, int off, int len)
           
 void reset()
           
 long skip(long n)
           
 
Methods inherited from class org.entityfs.support.io.InputStreamProxy
available, close, getProxied, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CountingInputStream

public CountingInputStream(InputStream wrapped)
Create a counting input stream that counts how many bytes that are read from the wrapped stream.

Parameters:
wrapped - The stream to read from.
Method Detail

read

public int read()
         throws IOException
Overrides:
read in class InputStreamProxy
Throws:
IOException

read

public int read(byte[] barr)
         throws IOException
Overrides:
read in class InputStreamProxy
Throws:
IOException

read

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

skip

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

mark

public void mark(int readlimit)
This method does nothing.

Overrides:
mark in class InputStreamProxy

reset

public void reset()
           throws IOException
Overrides:
reset in class InputStreamProxy
Throws:
IOException - Always.

markSupported

public boolean markSupported()
Overrides:
markSupported in class InputStreamProxy
Returns:
false, always.

getNoOfBytesReadOrSkipped

public long getNoOfBytesReadOrSkipped()
Get the number of bytes that the client has read from or skipped over in this stream.

Returns:
The number of bytes that the client has read from or skipped over in this stream.