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 EncodingOutputStream
base64
(OutputStream out) Creates a new instance that produces base64 output in the given stream.static EncodingOutputStream
base64
(OutputStream out, int lineLength) Creates a new instance that produces base64 output in the given stream.void
close()
void
flush()
static EncodingOutputStream
hex
(OutputStream out) Creates a new instance that produces hexadecimal output in the given stream.void
write
(byte[] b) void
write
(byte[] b, int off, int len) void
write
(int b) Methods inherited from class java.io.OutputStream
nullOutputStream
-
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:
write
in classFilterOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
flush
- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classFilterOutputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in 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.
-