Methods Summary |
---|
public synchronized long | getByteCount()The number of bytes that have passed through this stream.
NOTE: This method is an alternative for getCount()
and was added because that method returns an integer which will
result in incorrect count for files over 2GB.
return this.count;
|
public synchronized int | getCount()The number of bytes that have passed through this stream.
NOTE: From v1.3 this method throws an ArithmeticException if the
count is greater than can be expressed by an int .
See {@link #getByteCount()} for a method using a long .
long result = getByteCount();
if (result > Integer.MAX_VALUE) {
throw new ArithmeticException("The byte count " + result + " is too large to be converted to an int");
}
return (int) result;
|
public int | read(byte[] b)Reads a number of bytes into the byte array, keeping count of the
number read.
int found = super.read(b);
this.count += (found >= 0) ? found : 0;
return found;
|
public int | read(byte[] b, int off, int len)Reads a number of bytes into the byte array at a specific offset,
keeping count of the number read.
int found = super.read(b, off, len);
this.count += (found >= 0) ? found : 0;
return found;
|
public int | read()Reads the next byte of data adding to the count of bytes received
if a byte is successfully read.
int found = super.read();
this.count += (found >= 0) ? 1 : 0;
return found;
|
public synchronized long | resetByteCount()Set the byte count back to 0.
NOTE: This method is an alternative for resetCount()
and was added because that method returns an integer which will
result in incorrect count for files over 2GB.
long tmp = this.count;
this.count = 0;
return tmp;
|
public synchronized int | resetCount()Set the byte count back to 0.
NOTE: From v1.3 this method throws an ArithmeticException if the
count is greater than can be expressed by an int .
See {@link #resetByteCount()} for a method using a long .
long result = resetByteCount();
if (result > Integer.MAX_VALUE) {
throw new ArithmeticException("The byte count " + result + " is too large to be converted to an int");
}
return (int) result;
|
public long | skip(long length)Skips the stream over the specified number of bytes, adding the skipped
amount to the count.
final long skip = super.skip(length);
this.count += skip;
return skip;
|