public class NullInputStreamConsumer extends InputStreamConsumer
InputStream
, discarding what I read as I go, until I
encounter the end of the stream or an exception is thrown.
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.
exception, finishedChannel, stream
Constructor and Description |
---|
NullInputStreamConsumer(int bufferSize)
Creates an instance with the specified buffer size.
|
NullInputStreamConsumer(int bufferSize,
java.lang.String name)
Creates an instance with the specified buffer size and thread name.
|
NullInputStreamConsumer(int bufferSize,
java.lang.ThreadGroup group)
Creates an instance with the specified buffer size and thread group.
|
NullInputStreamConsumer(int bufferSize,
java.lang.ThreadGroup group,
java.lang.String name)
Creates an instance with the specified buffer size, thread group, and
thread name.
|
NullInputStreamConsumer(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 |
---|---|
java.nio.ByteBuffer |
data()
Returns the data consumed from my input stream.
|
protected void |
initialize(int bufferSize)
Initializes me with the specified buffer size.
|
protected int |
read()
Reads a chunk of data from my input stream.
|
exception, finishedChannel, finishedChannel, hasException, initialize, postProcessData, 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 NullInputStreamConsumer(int bufferSize)
super()
.bufferSize
- size of read buffer used if skip(long)
is not
supported by my input streampublic NullInputStreamConsumer(int bufferSize, java.lang.String name)
super(name)
.bufferSize
- size of read buffer used if skip(long)
is not
supported by my input streamname
- thread namepublic NullInputStreamConsumer(int bufferSize, java.lang.ThreadGroup group)
super(group)
.bufferSize
- size of read buffer used if skip(long)
is not
supported by my input streamgroup
- thread grouppublic NullInputStreamConsumer(int bufferSize, java.lang.ThreadGroup group, java.lang.String name)
super(group, name)
.bufferSize
- size of read buffer used if skip(long)
is not
supported by my input streamgroup
- thread groupname
- thread namepublic NullInputStreamConsumer(int bufferSize, java.lang.ThreadGroup group, java.lang.String name, long stackSize)
super(group, name, stackSize)
.bufferSize
- size of read buffer used if skip(long)
is not
supported by my input streamgroup
- thread groupname
- thread namestackSize
- thread stack sizeprotected void initialize(int bufferSize)
bufferSize
- size of read buffer used if skip(long)
is not
supported by my input streamprotected int read() throws java.io.IOException
InputStreamConsumer
read
in class InputStreamConsumer
java.io.IOException
- if an I/O error occurspublic java.nio.ByteBuffer data()
InputStreamConsumer
This method can be called safely from another thread only after
ensuring all my actions happen-before the action of calling this
method from the other thread. This is the Java memory model
happens-before relationship. For example, after I have been
started, it would be safe to call this method from another thread after
it called my join
method.
data
in class InputStreamConsumer