Package org.opencastproject.util
Class StreamConsumer
java.lang.Object
org.opencastproject.util.StreamConsumer
- All Implemented Interfaces:
Runnable
A StreamConsumer helps to asynchronously consume a text input stream line by line.
The consumer guarantees the closing of the stream.
-
Constructor Summary
ConstructorsConstructorDescriptionStreamConsumer(com.entwinemedia.fn.Fn<String, Boolean> consumer) Create a new stream consumer. -
Method Summary
Modifier and TypeMethodDescriptionvoidconsume(InputStream stream) Start consumingstream.voidrun()voidForcibly stop consuming the stream.voidWait until the stream has been fully consumed.voidWait for the executing thread to run.
-
Constructor Details
-
StreamConsumer
Create a new stream consumer.- Parameters:
consumer- a predicate function that may stop reading further lines by returningfalse
-
-
Method Details
-
run
public void run() -
waitUntilRunning
public void waitUntilRunning()Wait for the executing thread to run. -
waitUntilFinished
public void waitUntilFinished()Wait until the stream has been fully consumed. -
stopConsuming
public void stopConsuming()Forcibly stop consuming the stream. -
consume
Start consumingstream. It is guaranteed that the stream gets closed.
-