Package cx.ath.matthew.io
Class InOutCopier
java.lang.Object
java.lang.Thread
cx.ath.matthew.io.InOutCopier
- All Implemented Interfaces:
Runnable
Copies from an input stream to an output stream using a Thread.
example:
InputStream a = getInputStream(); OutputStream b = getOutputStream(); InOutCopier copier = new InOutCopier(a, b); copier.start(); <do stuff that writes to the inputstream>
-
Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
Thread.Builder, Thread.State, Thread.UncaughtExceptionHandler
-
Field Summary
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
-
Constructor Summary
ConstructorsConstructorDescriptionInOutCopier
(InputStream is, OutputStream os) Create a copier from an inputstream to an outputstream -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Force close the stream without waiting for EOF on the sourcevoid
flush()
Flush the outputstreamvoid
run()
Copies from the inputstream to the outputstream until EOF on the inputstream or explicitly closedvoid
start()
Start the thread and wait to make sure its really startedMethods inherited from class java.lang.Thread
activeCount, checkAccess, clone, countStackFrames, currentThread, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, isVirtual, join, join, join, join, ofPlatform, ofVirtual, onSpinWait, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, sleep, startVirtualThread, stop, suspend, threadId, toString, yield
-
Constructor Details
-
InOutCopier
Create a copier from an inputstream to an outputstream- Parameters:
is
- The stream to copy fromos
- the stream to copy to- Throws:
IOException
-
-
Method Details
-
close
public void close()Force close the stream without waiting for EOF on the source -
flush
Flush the outputstream- Throws:
IOException
-
start
public void start()Start the thread and wait to make sure its really started -
run
public void run()Copies from the inputstream to the outputstream until EOF on the inputstream or explicitly closed
-