Class BaseNCodecOutputStream<C extends BaseNCodec, T extends BaseNCodecOutputStream<C,T,B>, B extends BaseNCodecOutputStream.AbstractBuilder<T,C,B>>
java.lang.Object
java.io.OutputStream
java.io.FilterOutputStream
org.apache.commons.codec.binary.BaseNCodecOutputStream<C,T,B>
- Type Parameters:
C- A BaseNCodec subclass.T- A BaseNCodecInputStream subclass.B- A subclass.
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
- Direct Known Subclasses:
Base16OutputStream, Base32OutputStream, Base45OutputStream, Base58OutputStream, Base64OutputStream
public class BaseNCodecOutputStream<C extends BaseNCodec, T extends BaseNCodecOutputStream<C,T,B>, B extends BaseNCodecOutputStream.AbstractBuilder<T,C,B>>
extends FilterOutputStream
Abstract superclass for Base-N output streams.
To write the EOF marker without closing the stream, call eof() or use an Apache Commons
IO
CloseShieldOutputStream.
- Since:
- 1.5
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classBaseNCodecOutputStream.AbstractBuilder<T, C extends BaseNCodec, B extends BaseNCodecOutputStream.AbstractBuilder<T,C, B>> Builds output stream instances inBaseNCodecformat. -
Field Summary
Fields inherited from class FilterOutputStream
out -
Constructor Summary
ConstructorsModifierConstructorDescriptionBaseNCodecOutputStream(OutputStream outputStream, C basedCodec, boolean doEncode) Constructs a new instance.protectedConstructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this output stream and releases any system resources associated with the stream.voideof()Notifies the decoder or encoder of EOF (-1).voidflush()Flushes this output stream and forces any buffered output bytes to be written out to the stream.booleanTests whether decoding behavior is strict.voidwrite(byte[] array, int offset, int len) Writeslenbytes from the specifiedbarray starting atoffsetto this output stream.voidwrite(int i) Writes the specifiedbyteto this output stream.Methods inherited from class FilterOutputStream
write
-
Constructor Details
-
BaseNCodecOutputStream
Constructs a new instance.- Parameters:
builder- A builder.- Since:
- 1.20.0
-
BaseNCodecOutputStream
Constructs a new instance. TODO should this be protected?- Parameters:
outputStream- The underlying output or null.basedCodec- A BaseNCodec.doEncode- true to encode, false to decode, TODO should be an enum?.
-
-
Method Details
-
close
Closes this output stream and releases any system resources associated with the stream.The underlying stream is closed even if final conversion or flushing fails. If closing also fails, its exception is suppressed on the original exception.
To write the EOF marker without closing the stream, call
eof()or use an Apache Commons IO CloseShieldOutputStream.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterOutputStream- Throws:
IOException- Thrown if an I/O error occurs.
-
eof
Notifies the decoder or encoder of EOF (-1).- Throws:
IOException- Thrown when a problem is detected processing data.- Since:
- 1.11
-
flush
Flushes this output stream and forces any buffered output bytes to be written out to the stream.- Specified by:
flushin interfaceFlushable- Overrides:
flushin classFilterOutputStream- Throws:
IOException- Thrown if an I/O error occurs.
-
isStrictDecoding
Tests whether decoding behavior is strict.Strict decoding rejects invalid trailing bits and, for Base32 and Base64, noncanonical input. Decoding errors are reported as
IOException. To complete validation, calleof()orclose(). Decoded bytes can be emitted before a later validation error.- Returns:
- true if using strict decoding.
- Since:
- 1.15
-
write
Writeslenbytes from the specifiedbarray starting atoffsetto this output stream.- Overrides:
writein classFilterOutputStream- Parameters:
array- source byte array.offset- where to start reading the bytes.len- maximum number of bytes to write.- Throws:
IOException- Thrown if an I/O error occurs.NullPointerException- Thrown if the byte array parameter is null.IndexOutOfBoundsException- Thrown if the offset, length, or buffer size is invalid.
-
write
Writes the specifiedbyteto this output stream.- Overrides:
writein classFilterOutputStream- Parameters:
i- source byte.- Throws:
IOException- Thrown if an I/O error occurs.
-