Package org.cryptacular.io
Class EncodingOutputStream
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.cryptacular.io.EncodingOutputStream
- All Implemented Interfaces:
Closeable,Flushable,AutoCloseable
Filters written bytes through an
Encoder such that encoded data is written to the underlying output stream.- Author:
- Middleware Services
-
Field Summary
Fields inherited from class java.io.FilterOutputStream
out -
Constructor Summary
ConstructorsConstructorDescriptionEncodingOutputStream(OutputStream out, Encoder e) Creates a new instance that wraps the given stream and performs encoding using the given encoder component. -
Method Summary
Modifier and TypeMethodDescriptionstatic EncodingOutputStreambase64(OutputStream out) Creates a new instance that produces base64 output in the given stream.static EncodingOutputStreambase64(OutputStream out, int lineLength) Creates a new instance that produces base64 output in the given stream.voidclose()voidflush()static EncodingOutputStreamhex(OutputStream out) Creates a new instance that produces hexadecimal output in the given stream.voidwrite(byte[] b) voidwrite(byte[] b, int off, int len) voidwrite(int b)
-
Constructor Details
-
EncodingOutputStream
Creates a new instance that wraps the given stream and performs encoding using the given encoder component.- Parameters:
out- Output stream to wrap.e- Encoder that provides on-the-fly encoding.
-
-
Method Details
-
write
- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
write
- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
write
- Overrides:
writein classFilterOutputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceFlushable- Overrides:
flushin classFilterOutputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterOutputStream- Throws:
IOException
-
base64
Creates a new instance that produces base64 output in the given stream.NOTE: there are no line breaks in the output with this version.
- Parameters:
out- Wrapped output stream.- Returns:
- Encoding output stream that produces base64 output.
-
base64
Creates a new instance that produces base64 output in the given stream.NOTE: this version supports output with configurable line breaks.
- Parameters:
out- Wrapped output stream.lineLength- Length of each base64-encoded line in output. A zero or negative value disables line breaks.- Returns:
- Encoding output stream that produces base64 output.
-
hex
Creates a new instance that produces hexadecimal output in the given stream.NOTE: there are no line breaks in the output.
- Parameters:
out- Wrapped output stream.- Returns:
- Encoding output stream that produces hexadecimal output.
-