Package nl.vpro.util
Class Copier
java.lang.Object
nl.vpro.util.Copier
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Runnable
Can be used to copy an
InputStream
to an OutputStream
in a stand alone thread.
Used by FileCachingInputStream
.- Since:
- 3.1
- Author:
- Michiel Meeuwissen
-
Nested Class Summary
-
Constructor Summary
ConstructorDescriptionCopier
(@NonNull InputStream i, @NonNull OutputStream o) Copier
(@NonNull InputStream i, @NonNull OutputStream o, Long batch) -
Method Summary
Modifier and TypeMethodDescriptionint
static Copier.Builder
builder()
void
close()
Closes and interrupts the copier if necessary (This may be desired if it was detected that the receiver is no longer interested).execute()
boolean
long
getCount()
Returns the number of bytes read from the input stream so farFuture<?>
boolean
isReady()
Checks whether this copier is ready.boolean
Checks whether this copier is ready, but will throw anIOException
it it did not _successfully_ finish.void
run()
toString()
void
waitFor()
void
-
Constructor Details
-
Copier
-
Copier
-
-
Method Details
-
run
public void run() -
waitFor
- Throws:
InterruptedException
-
waitForAndClose
- Throws:
InterruptedException
IOException
-
isReadyIOException
Checks whether this copier is ready, but will throw anIOException
it it did not _successfully_ finish.- Throws:
IOException
-
getException
-
getCount
public long getCount()Returns the number of bytes read from the input stream so far -
execute
-
executeIfNotRunning
public boolean executeIfNotRunning() -
close
Closes and interrupts the copier if necessary (This may be desired if it was detected that the receiver is no longer interested). And closes associated resources.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
available
- Throws:
IOException
-
toString
-
builder
-
isReady
public boolean isReady()Checks whether this copier is ready. You may want to check or use to deal with unsuccessful terminations -
getFuture
-