Class StreamPlugThread
java.lang.Object
ecmwf.common.technical.ThreadService.ConfigurableRunnable
ecmwf.common.technical.StreamPlugThread
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThe Class StreamCloseable. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe Constant DEFAULT_BUFF_SIZE. -
Constructor Summary
ConstructorsConstructorDescriptionStreamPlugThread(InputStream in, OutputStream out) Instantiates a new stream plug thread. -
Method Summary
Modifier and TypeMethodDescriptionbooleanalive()Alive.voidclose()Close.static voidcloseQuietly(Closeable closeable) Close quietly.static voidcloseQuietly(AutoCloseable closeable) Close quietly.static voidcloseQuietly(Process process) Close quietly.static voidcloseQuietly(ServerSocket serverSocket) Close quietly.static voidcloseQuietly(Socket socket) Close quietly.static voidcloseQuietly(Scanner scanner) Close quietly.voidConfigurable run.static longconsume(InputStream in, int bufferSize) Just consume the input stream, but do nothing with it.static longcopy(OutputStream out, InputStream in, int bufferSize) Copy.static longcopy(OutputStream out, InputStream in, int bufferSize, long size) Copy.voidflush()Flush the underlying output stream.intGets the buff size.static StringgetExceptionMessage(String input) Gets the exception message.booleangetFlush()Gets the flush.Gets the message.booleanGets the read fully.static voidplugTogether(Socket source, InputStream in, OutputStream out, Closeable toClose) Plug together.static voidplugTogether(Socket source, Socket target, Closeable... toClose) Plug together.static intreadFully(InputStream in, byte[] b, int off, int len) Read fully.voidsetBuffSize(int buffSize) Sets the buff size.voidsetFlush(boolean flush) Sets the flush.voidsetReadFully(boolean readFully) Sets the read fully.voidSpecify which Closeable object should be closed when the plug is closed.voidSpecify which Closeable objects should be closed when the plug is closed.Methods inherited from class ecmwf.common.technical.ThreadService.ConfigurableRunnable
execute, execute, getContextClassLoader, getPriority, getThreadName, interrupt, interrupted, isAlive, isStarted, join, join, run, setContextClassLoader, setForceCookie, setInheritCookie, setPriority, setThreadNameAndCookie
-
Field Details
-
DEFAULT_BUFF_SIZE
public static final int DEFAULT_BUFF_SIZEThe Constant DEFAULT_BUFF_SIZE.
-
-
Constructor Details
-
StreamPlugThread
Instantiates a new stream plug thread.- Parameters:
in- the inout- the out
-
-
Method Details
-
setBuffSize
public void setBuffSize(int buffSize) Sets the buff size.- Parameters:
buffSize- the new buff size
-
getBuffSize
public int getBuffSize()Gets the buff size.- Returns:
- the buff size
-
setFlush
public void setFlush(boolean flush) Sets the flush.- Parameters:
flush- the new flush
-
getFlush
public boolean getFlush()Gets the flush.- Returns:
- the flush
-
setReadFully
public void setReadFully(boolean readFully) Sets the read fully.- Parameters:
readFully- the new read fully
-
getReadFully
public boolean getReadFully()Gets the read fully.- Returns:
- the read fully
-
alive
public boolean alive()Alive.- Returns:
- true, if successful
-
close
public void close()Close.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable
-
getMessage
-
plugTogether
public static void plugTogether(Socket source, Socket target, Closeable... toClose) throws IOException Plug together.- Parameters:
source- the sourcetarget- the targettoClose- the to close- Throws:
IOException- Signals that an I/O exception has occurred.
-
plugTogether
public static void plugTogether(Socket source, InputStream in, OutputStream out, Closeable toClose) throws IOException Plug together.- Parameters:
source- the sourcein- the inout- the outtoClose- the to close- Throws:
IOException- Signals that an I/O exception has occurred.
-
readFully
Read fully.- Parameters:
in- the inb- the boff- the offlen- the len- Returns:
- the int
- Throws:
IOException- Signals that an I/O exception has occurred.
-
copy
Copy.- Parameters:
out- the outin- the inbufferSize- the buffer size- Returns:
- the long
- Throws:
IOException- Signals that an I/O exception has occurred.
-
copy
public static long copy(OutputStream out, InputStream in, int bufferSize, long size) throws IOException Copy.- Parameters:
out- the outin- the inbufferSize- the buffer sizesize- the size- Returns:
- the long
- Throws:
IOException- Signals that an I/O exception has occurred.
-
consume
Just consume the input stream, but do nothing with it.- Parameters:
in- the inbufferSize- the buffer size- Returns:
- the long
- Throws:
IOException- Signals that an I/O exception has occurred.
-
closeQuietly
-
closeQuietly
-
closeQuietly
Close quietly.- Parameters:
closeable- the closeable
-
closeQuietly
Close quietly.- Parameters:
closeable- the closeable
-
closeQuietly
-
closeQuietly
Close quietly.- Parameters:
serverSocket- the server socket
-
flush
Flush the underlying output stream.- Throws:
IOException- Signals that an I/O exception has occurred.
-
configurableRun
public void configurableRun()Configurable run. Configurable run.- Specified by:
configurableRunin classThreadService.ConfigurableRunnable
-
getExceptionMessage
-
toClose
Specify which Closeable objects should be closed when the plug is closed.- Parameters:
toClose- the close
-
toClose
Specify which Closeable object should be closed when the plug is closed.- Parameters:
toClose- the to close
-