|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
java.io.FilterInputStream
com.anthonyeden.lib.io.ByteCountInputStream
A FilterInputStream which will keep track of the number of bytes read from the underlying stream. Callers who want to know how many bytes have been read 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.FilterInputStream |
in |
Constructor Summary | |
ByteCountInputStream(java.io.InputStream in)
Construct a new ByteCountInputStream. |
Method Summary | |
void |
addChangeListener(javax.swing.event.ChangeListener l)
Add a ChangeListener. |
protected void |
fireStateChanged()
Fire a ChangeEvent. |
protected java.util.ArrayList |
getChangeListeners()
Get a List of attached ChangeListeners. |
long |
getCount()
Get the number of bytes read so far. |
int |
read()
Read one byte. |
int |
read(byte[] buffer)
Fill the buffer with bytes until the buffer is full, the stream blocks, or until the end of the stream. |
int |
read(byte[] buffer,
int offset,
int length)
Fill the buffer with bytes starting at the given offset of the buffer and reading for length number of bytes. |
void |
removeChangeListener(javax.swing.event.ChangeListener l)
Remove the ChangeListener. |
Methods inherited from class java.io.FilterInputStream |
available, close, mark, markSupported, reset, skip |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public ByteCountInputStream(java.io.InputStream in)
in
- The input stream to countMethod Detail |
public void addChangeListener(javax.swing.event.ChangeListener l)
l
- The ChangeListenerpublic void removeChangeListener(javax.swing.event.ChangeListener l)
l
- The ChangeListenerpublic int read(byte[] buffer) throws java.io.IOException
buffer
- The buffer to fill
java.io.IOException
public int read(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 read
java.io.IOException
public int read() 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 |