|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.io.InputStream
com.mucommander.io.CounterInputStream
public class CounterInputStream
An InputStream that keeps track of the number of bytes that have been read from it. Bytes that are skipped (using
skip(long) are by default accounted for, setCountSkippedBytes(boolean) can be used to change this.
The actual number of bytes can be retrieved from the ByteCounter instance returned by getCounter().
The CounterInputStream(InputStream, ByteCounter) constructor can be used to specify an existing
ByteCounter instance instead of creating a new one. The ByteCounter will always remain accessible, even
after this stream has been closed.
ByteCounter| Constructor Summary | |
|---|---|
CounterInputStream(java.io.InputStream in)
Creates a new CounterInputStream using the specified InputStream. |
|
CounterInputStream(java.io.InputStream in,
ByteCounter counter)
Creates a new CounterInputStream using the specified InputStream and ByteCounter. |
|
| Method Summary | |
|---|---|
int |
available()
|
void |
close()
|
ByteCounter |
getCounter()
Returns the ByteCounter that holds the number of bytes that have been read (and optionally skipped) from this InputStream. |
boolean |
getCountSkippedBytes()
Returns true if skipped bytes (using skip(long) are accounted for. |
void |
mark(int readLimit)
|
boolean |
markSupported()
|
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
void |
reset()
|
void |
setCountSkippedBytes(boolean countSkippedBytes)
Specifies whether or not skipped bytes (using skip(long) should be accounted for. |
long |
skip(long n)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CounterInputStream(java.io.InputStream in)
ByteCounter will be created.
in - the underlying InputStream the data will be read from
public CounterInputStream(java.io.InputStream in,
ByteCounter counter)
ByteCounter.
The provided ByteCounter will NOT be reset, whatever value it contains will be kept.
in - the underlying InputStream the data will be read from| Method Detail |
|---|
public ByteCounter getCounter()
public void setCountSkippedBytes(boolean countSkippedBytes)
skip(long) should be accounted for.
This is by default enabled, bytes that are skipped are added to the ByteCounter.
countSkippedBytes - if true, skipped bytes will be accounted for, the ByteCounter will be increased
by the number of skipped bytespublic boolean getCountSkippedBytes()
skip(long) are accounted for.
This is by default enabled, bytes that are skipped are added to the ByteCounter.
public int read()
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOException
public int read(byte[] b)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOException
public int read(byte[] b,
int off,
int len)
throws java.io.IOException
read in class java.io.InputStreamjava.io.IOException
public long skip(long n)
throws java.io.IOException
skip in class java.io.InputStreamjava.io.IOException
public int available()
throws java.io.IOException
available in class java.io.InputStreamjava.io.IOException
public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in class java.io.InputStreamjava.io.IOExceptionpublic void mark(int readLimit)
mark in class java.io.InputStreampublic boolean markSupported()
markSupported in class java.io.InputStream
public void reset()
throws java.io.IOException
reset in class java.io.InputStreamjava.io.IOException
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
This file is part of muCommander - Copyright (C) 2002-2008 Maxence Bernard