# Class CountInputStream

java.lang.Object
java.io.InputStream
java.io.FilterInputStream
uk.ac.starlink.util.CountInputStream

All Implemented Interfaces:
  `Closeable, AutoCloseable`

public class CountInputStream extends FilterInputStream
Filter input stream that counts the number of bytes read.

Since:
  9 May 2014
Author:
  Mark Taylor

## Field Summary

### Fields inherited from class FilterInputStream

`in`

## Constructor Summary

Constructors
Constructor
Description
`CountInputStream(InputStream in)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`long`
`getReadCount()`
Returns the number of bytes successfully read so far from this stream.
`long`
`getSkipCount()`
Returns the number of bytes skipped from this stream.
`int`
`read()`
`int`
`read(byte[] b)`
`int`
`read(byte[] b, int off, int len)`
`long`
`skip(long n)`

### Methods inherited from class FilterInputStream

`available, close, mark, markSupported, reset`

### Methods inherited from class InputStream

`nullInputStream, readAllBytes, readNBytes, readNBytes, skipNBytes, transferTo`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### CountInputStream

public CountInputStream(InputStream in)
Constructor.

Parameters:
  `in` - base input stream

## Method Details

### read

public int read() throws IOException

Overrides:
  `read` in class `FilterInputStream`
Throws:
  `IOException`

### read

public int read(byte[] b) throws IOException

Overrides:
  `read` in class `FilterInputStream`
Throws:
  `IOException`

### read

public int read(byte[] b, int off, int len) throws IOException

Overrides:
  `read` in class `FilterInputStream`
Throws:
  `IOException`

### skip

public long skip(long n) throws IOException

Overrides:
  `skip` in class `FilterInputStream`
Throws:
  `IOException`

### getReadCount

public long getReadCount()
Returns the number of bytes successfully read so far from this stream.

Returns:
  number of bytes read

### getSkipCount

public long getSkipCount()
Returns the number of bytes skipped from this stream.

Returns:
  number of bytes skipped