Top Description Fields Constructors Methods
org.apache.commons.compress.utils

public Class CountingInputStream

extends FilterInputStream
Class Inheritance
Annotations
@Deprecated
Imports
java.io.FilterInputStream, .IOException, .InputStream

Deprecated

Use org.apache.commons.io.input.CountingInputStream.

Input stream that tracks the number of bytes read.
Since
1.3

Field Summary

Modifier and TypeField and Description
private long
Inherited from java.io.FilterInputStream:
in

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected final void
count(final long
the number of bytes read
read
)

Increments the counter of already read bytes.

public long

Returns:

the number of read bytes
getBytesRead
()

Returns the current number of bytes read from this stream.

public int
read()

Overrides java.io.FilterInputStream.read.

Reads the next byte of data from the input stream.
public int
read(final byte[]
the buffer into which the data is read.
b
)

Overrides java.io.FilterInputStream.read.

Reads up to b.length bytes of data from this input stream into an array of bytes.
public int
read(final byte[]
the buffer into which the data is read.
b
,
final int
the start offset in array b at which the data is written.
off
,
final int
the maximum number of bytes to read.
len
)

Overrides java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes.
Inherited from java.io.FilterInputStream:
availableclosemarkmarkSupportedresetskip

Field Detail

bytesReadback to summary
private long bytesRead

Constructor Detail

CountingInputStreamback to summary
public CountingInputStream(final InputStream in)

Method Detail

countback to summary
protected final void count(final long read)

Increments the counter of already read bytes. Doesn't increment if the EOF has been hit (read == -1)

Parameters
read:long

the number of bytes read

getBytesReadback to summary
public long getBytesRead()

Returns the current number of bytes read from this stream.

Returns:long

the number of read bytes

readback to summary
public int read() throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads the next byte of data from the input stream. The value byte is returned as an int in the range 0 to 255. If no byte is available because the end of the stream has been reached, the value -1 is returned. This method blocks until input data is available, the end of the stream is detected, or an exception is thrown.

Returns:int

the next byte of data, or -1 if the end of the stream is reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(final byte[] b) throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads up to b.length bytes of data from this input stream into an array of bytes. This method blocks until some input is available.

Parameters
b:byte[]

the buffer into which the data is read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(final byte[] b, final int off, final int len) throws IOException

Overrides java.io.FilterInputStream.read.

Doc from java.io.FilterInputStream.read.

Reads up to len bytes of data from this input stream into an array of bytes. If len is not zero, the method blocks until some input is available; otherwise, no bytes are read and 0 is returned.

Parameters
b:byte[]

the buffer into which the data is read.

off:int

the start offset in array b at which the data is written.

len:int

the maximum number of bytes to read.

Returns:int

the total number of bytes read into the buffer, or -1 if there is no more data because the end of the stream has been reached.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.