Top Description Fields Constructors Methods
org.tukaani.xz

pack-priv Class CountingInputStream

extends CloseIgnoringInputStream
Class Inheritance
Imports
java.io.FilterInputStream, .InputStream, .IOException

Counts the number of bytes read from an input stream. The close() method does nothing, that is, the underlying InputStream isn't closed.

Field Summary

Modifier and TypeField and Description
private long

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public long
public int
read()

Overrides java.io.FilterInputStream.read.

Reads the next byte of data from the input stream.
public int
read(byte[]
the buffer into which the data is read.
b
,
int
the start offset in array b at which the data is written.
off
,
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 org.tukaani.xz.CloseIgnoringInputStream:
close

Field Detail

sizeback to summary
private long size

Constructor Detail

CountingInputStreamback to summary
public CountingInputStream(InputStream in)

Method Detail

getSizeback to summary
public long getSize()
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.

Exceptions
IOException:
if an I/O error occurs.
readback to summary
public int read(byte[] b, int off, 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.

Exceptions
IOException:
if an I/O error occurs.