|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.io.OutputStream java.io.FilterOutputStream com.anthonyeden.lib.io.ByteCountOutputStream
A FilterOutputStream which will keep track of the number of bytes written to the underlying stream. Callers who want to know how many bytes have been written should attach a ChangeListener and call getCount() whenever a change event is fired.
If no ChangeListeners are attached then this stream will not fire events. This improves performance by only firing events when at least one object is expecting them.
Field Summary |
Fields inherited from class java.io.FilterOutputStream |
out |
Constructor Summary | |
ByteCountOutputStream(java.io.OutputStream out)
|
Method Summary | |
void |
addChangeListener(javax.swing.event.ChangeListener l)
Add a changeListeners. |
protected void |
fireStateChanged()
Fire a ChangeEvent. |
protected java.util.ArrayList |
getChangeListeners()
Get a List of attached ChangeListeners. |
long |
getCount()
Get the number of bytes written so far. |
void |
removeChangeListener(javax.swing.event.ChangeListener l)
Remove a ChangeListener. |
void |
write(byte[] buffer)
Write the buffer to the stream. |
void |
write(byte[] buffer,
int offset,
int length)
Write the buffer to the stream with bytes starting at the given offset of the buffer and reading for length number of bytes. |
void |
write(int b)
Write one byte. |
Methods inherited from class java.io.FilterOutputStream |
close, flush |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ByteCountOutputStream(java.io.OutputStream out)
Method Detail |
public void addChangeListener(javax.swing.event.ChangeListener l)
l
- The ChangeListenerpublic void removeChangeListener(javax.swing.event.ChangeListener l)
l
- The ChangeListenerpublic void write(byte[] buffer) throws java.io.IOException
buffer
- The buffer to write
java.io.IOException
public void write(byte[] buffer, int offset, int length) throws java.io.IOException
length
number of bytes.
buffer
- The bufferoffset
- The buffer offsetlength
- The number of bytes to write
java.io.IOException
public void write(int b) throws java.io.IOException
java.io.IOException
public long getCount()
protected java.util.ArrayList getChangeListeners()
protected void fireStateChanged()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |