public class FixedSizeBufferInputStreamConsumer extends BufferInputStreamConsumer
InputStream
, placing what I read into a fixed-size
buffer, until I encounter the end of the stream or an exception is
thrown. If I read more bytes than will fit in the buffer, the buffer will
contain the most recent buffer-size bytes read.
I check my interrupted status when I can, but I will usually not see that
I have been interrupted since I will almost always be blocked reading my
InputStream
which is not an interruptible channel. So, the best
way to get me to die is to close the InputStream
I am reading.
buffer, bufferPosition
exception, finishedChannel, stream
Constructor and Description |
---|
FixedSizeBufferInputStreamConsumer(int bufferSize)
Creates an instance with the specified buffer size.
|
FixedSizeBufferInputStreamConsumer(int bufferSize,
java.lang.String name)
Creates an instance with the specified buffer size and thread name.
|
FixedSizeBufferInputStreamConsumer(int bufferSize,
java.lang.ThreadGroup group)
Creates an instance with the specified buffer size and thread group.
|
FixedSizeBufferInputStreamConsumer(int bufferSize,
java.lang.ThreadGroup group,
java.lang.String name)
Creates an instance with the specified buffer size, thread group, and
thread name.
|
FixedSizeBufferInputStreamConsumer(int bufferSize,
java.lang.ThreadGroup group,
java.lang.String name,
long stackSize)
Creates an instance with the specified buffer size, thread group,
thread name, and thread stack size.
|
Modifier and Type | Method and Description |
---|---|
protected void |
initialize(int bufferSize)
Initializes me with the specified buffer size.
|
protected void |
postProcessData()
Performs post-processing of data, and is invoked from my
run()
method after a call to InputStreamConsumer.read() returns indicating
end-of-stream. |
protected int |
read()
Reads a chunk of data from my input stream.
|
data
exception, finishedChannel, finishedChannel, hasException, initialize, run, stream, stream
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public FixedSizeBufferInputStreamConsumer(int bufferSize)
super(bufferSize)
.bufferSize
- size of the buffer into which I read data from my
input streampublic FixedSizeBufferInputStreamConsumer(int bufferSize, java.lang.String name)
super(bufferSize, name)
.bufferSize
- size of the buffer into which I read data from my
input streamname
- thread namepublic FixedSizeBufferInputStreamConsumer(int bufferSize, java.lang.ThreadGroup group)
super(bufferSize, group)
.bufferSize
- size of the buffer into which I read data from my
input streamgroup
- thread grouppublic FixedSizeBufferInputStreamConsumer(int bufferSize, java.lang.ThreadGroup group, java.lang.String name)
super(bufferSize, group, name)
.bufferSize
- size of the buffer into which I read data from my
input streamgroup
- thread groupname
- thread namepublic FixedSizeBufferInputStreamConsumer(int bufferSize, java.lang.ThreadGroup group, java.lang.String name, long stackSize)
super(bufferSize, group, name, stackSize)
.bufferSize
- size of the buffer into which I read data from my
input streamgroup
- thread groupname
- thread namestackSize
- thread stack sizeprotected void initialize(int bufferSize)
BufferInputStreamConsumer
initialize
in class BufferInputStreamConsumer
bufferSize
- size of the buffer into which I read data from my
input streamprotected int read() throws java.io.IOException
InputStreamConsumer
read
in class InputStreamConsumer
java.io.IOException
- if an I/O error occursprotected void postProcessData()
InputStreamConsumer
run()
method after a call to InputStreamConsumer.read()
returns indicating
end-of-stream.
This method does nothing, but subclasses may override it to do
something.postProcessData
in class InputStreamConsumer