Package com.storedobject.common
Class InputOutputStream
java.lang.Object
com.storedobject.common.InputOutputStream
- All Implemented Interfaces:
AutoCloseable
A class that combines an
InputStream and an OutputStream. One thread may be writing to it and another
may be reading from it.- Author:
- Syam
-
Constructor Summary
ConstructorsConstructorDescriptionConstructor with a default buffer size of 8K.InputOutputStream(int bufferSize) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Abort the streams.voidclose()Get the input stream for reading.Get the output stream for writing to it.final booleanCheck whether this is reusable or not.voidsetDataListener(Runnable dataListener) Sets a listener that will be executed when specific data-related events occur.voidSet an exception to the input stream so that someone will get it when they try to read something from it.voidsetReusable(boolean reusable) Set this in 'reusable' mode.
-
Constructor Details
-
InputOutputStream
public InputOutputStream()Constructor with a default buffer size of 8K. -
InputOutputStream
public InputOutputStream(int bufferSize) Constructor.- Parameters:
bufferSize- Buffer size
-
-
Method Details
-
getInputStream
-
getOutputStream
Get the output stream for writing to it.- Returns:
- Output stream.
-
isReusable
public final boolean isReusable()Check whether this is reusable or not. (When set to 'reusable' mode, the buffer will be reset and it will possible to start reading from and writing to it again.)- Returns:
- True or false.
-
setReusable
public void setReusable(boolean reusable) Set this in 'reusable' mode. (When set to 'reusable' mode, the buffer will be reset and it will possible to start reading from and writing to it again.)- Parameters:
reusable- True or false
-
abort
public void abort()Abort the streams. After this operation, this can not be reused too. -
setExternalException
Set an exception to the input stream so that someone will get it when they try to read something from it.- Parameters:
e- Exception to set.
-
setDataListener
-
close
- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-