|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.mucommander.io.ByteCounter
public class ByteCounter
Contains a number of bytes which have been read/written from/to a CounterInputStream/CounterOutputStream.
Provided methods allow to read the the byte count, add a number bytes to it or reset it (make it zero).
This class is thread safe, ensuring that the counter is always in a consistent state.
CounterInputStream,
CounterOutputStream| Constructor Summary | |
|---|---|
ByteCounter()
Creates a new ByteCounter with an initial byte count equal to zero. |
|
ByteCounter(ByteCounter counter)
Creates a new ByteCounter with an initial byte count equal to zero and using the given ByteCounter. |
|
| Method Summary | |
|---|---|
void |
add(ByteCounter counter,
boolean resetAfter)
Increases the byte counter by the number of bytes contained in the specified counter (as returned by its getByteCount() method) and resets its byte counter after (if specified). |
void |
add(long nbBytes)
Increases the byte counter by the provided number of bytes. |
long |
getByteCount()
Return the number of bytes which have been accounted for. |
void |
reset()
Resets the byte counter (make it zero). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public ByteCounter()
public ByteCounter(ByteCounter counter)
The value returned by getByteCount() will be the sum of the internal byte count and the one from
the specified ByteCounter, as returned by its getByteCount() method. Resetting this ByteCounter's value
will only affect the internal byte count and not the one from the specified ByteCounter.
| Method Detail |
|---|
public long getByteCount()
public void add(long nbBytes)
nbBytes - number of bytes to add to the byte counter, will be ignored if negative
public void add(ByteCounter counter,
boolean resetAfter)
getByteCount() method) and resets its byte counter after (if specified).
counter - the Bytecounter to add to this one, and reset after (if specified).resetAfter - if true, the specified counter will be reset after its byte count has been added to this ByteCounterpublic void reset()
|
|||||||||
| 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