public class InputStreamConsumer extends Thread
Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CHUNK_SIZE |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
InputStreamConsumer(InputStream input)
Constructor.
|
InputStreamConsumer(InputStream input,
int chunkSize,
String type,
IInputStreamListener... listeners)
Constructor.
|
InputStreamConsumer(InputStream input,
String type,
IInputStreamListener... listeners)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
afterStreaming()
Invoked just after steaming ended, before the thread dies.
|
protected void |
beforeStreaming()
Invoked just before steaming begins, in a new thread.
|
static void |
consume(InputStream input)
Convenience method for creasing a consumer instance and starting it.
|
static void |
consume(InputStream input,
int chunkSize,
String type,
IInputStreamListener... listeners)
Convenience method for creasing a consumer instance, starting it,
and waiting for it to complete.
|
static void |
consume(InputStream input,
String type,
IInputStreamListener... listeners)
Convenience method for creasing a consumer instance and starting it.
|
static void |
consumeAndWait(InputStream input)
Convenience method for creasing a consumer instance, starting it,
and waiting for it to complete.
|
static void |
consumeAndWait(InputStream input,
int chunkSize,
String type,
IInputStreamListener... listeners)
Convenience method for creasing a consumer instance, starting it,
and waiting for it to complete.
|
static void |
consumeAndWait(InputStream input,
String type,
IInputStreamListener... listeners)
Convenience method for creasing a consumer instance and starting it.
|
IInputStreamListener[] |
getStreamListeners()
Returns stream listeners.
|
String |
getType()
Gets the stream type or
null if no type was set. |
void |
run() |
void |
startAndWait()
Starts this consumer thread and wait for it to complete before returning.
|
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 static final int DEFAULT_CHUNK_SIZE
public InputStreamConsumer(InputStream input)
input
- input streampublic InputStreamConsumer(InputStream input, String type, IInputStreamListener... listeners)
input
- input streamtype
- an optional way to identify each portion being read to
stream listeners. Useful when listeners are shared.
Can be null
.listeners
- input stream listenerspublic InputStreamConsumer(InputStream input, int chunkSize, String type, IInputStreamListener... listeners)
input
- input streamchunkSize
- how many bytes to read at once before (will also
be the maximum byte array size sent to listeners)type
- an optional way to identify each portion being read to
stream listeners. Useful when listeners are shared.
Can be null
.listeners
- input stream listenerspublic IInputStreamListener[] getStreamListeners()
public String getType()
null
if no type was set.protected void beforeStreaming()
protected void afterStreaming()
public void startAndWait()
StreamException
- if streaming is interrupted while waitingpublic static void consume(InputStream input)
input
- input stream to consume.public static void consume(InputStream input, String type, IInputStreamListener... listeners)
input
- input streamtype
- an optional way to identify each portion being read to
stream listeners. Useful when listeners are shared.
Can be null
.listeners
- input stream listenerspublic static void consume(InputStream input, int chunkSize, String type, IInputStreamListener... listeners)
input
- input streamchunkSize
- how many bytes to read at once before (will also
be the maximum byte array size sent to listeners)type
- an optional way to identify each portion being read to
stream listeners. Useful when listeners are shared.
Can be null
.listeners
- input stream listenerspublic static void consumeAndWait(InputStream input)
input
- input stream to consume.public static void consumeAndWait(InputStream input, String type, IInputStreamListener... listeners)
input
- input streamtype
- an optional way to identify each portion being read to
stream listeners. Useful when listeners are shared.
Can be null
.listeners
- input stream listenerspublic static void consumeAndWait(InputStream input, int chunkSize, String type, IInputStreamListener... listeners)
input
- input streamchunkSize
- how many bytes to read at once before (will also
be the maximum byte array size sent to listeners)type
- an optional way to identify each portion being read to
stream listeners. Useful when listeners are shared.
Can be null
.listeners
- input stream listenersCopyright © 2008–2021 Norconex Inc.. All rights reserved.