Package com.storedobject.common
Class TranslatedOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
com.storedobject.common.TranslatedOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
A
FilterOutputStream that translates its stream on-the-fly while writing.- Author:
- Syam
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final BufferedInputStreamABufferedInputStreamused to read input data that needs to be translated before being written to the underlying output stream.protected final OutputStreamThe underlying output stream to which the translated data is written. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedCreates a new translated output stream. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidTranslation should be done here.Methods inherited from class java.io.OutputStream
nullOutputStream
-
Field Details
-
in
ABufferedInputStreamused to read input data that needs to be translated before being written to the underlying output stream. This variable is intended to serve as the source of data for the translation process. Thetranslate()method of the enclosing class should read data from this stream, perform the translation, and write the results to the output stream. -
out
The underlying output stream to which the translated data is written. This stream serves as the destination for the data after it has been translated by thetranslate()method of the enclosingTranslatedOutputStreamclass. The data processed from theBufferedInputStreamvariableinis transformed and ultimately written to this stream. This field is final, ensuring that the reference to the output stream cannot be reassigned after initialization.
-
-
Constructor Details
-
TranslatedOutputStream
Creates a new translated output stream.- Parameters:
out- OutputStream object providing the underlying stream.
-
-
Method Details
-
translate
Translation should be done here. Original output stream is available in the variableoutand the translated output should be written to it by reading theBufferedInputStream(variablein) and translating it (i.e., read from 'in', translate and write to 'out')- Throws:
Exception- Throws any exception so that the ultimate reading program will get it.
-