Package org.apache.commons.codec.binary
Class BaseNCodecOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- org.apache.commons.codec.binary.BaseNCodecOutputStream
-
- All Implemented Interfaces:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
- Direct Known Subclasses:
Base32OutputStream
,Base64OutputStream
public class BaseNCodecOutputStream extends java.io.FilterOutputStream
Abstract superclass for Base-N output streams.- Since:
- 1.5
- Version:
- $Id: BaseNCodecOutputStream.java 1544347 2013-11-21 22:30:31Z ggregory $
-
-
Field Summary
Fields Modifier and Type Field Description private BaseNCodec
baseNCodec
private BaseNCodec.Context
context
private boolean
doEncode
private byte[]
singleByte
-
Constructor Summary
Constructors Constructor Description BaseNCodecOutputStream(java.io.OutputStream out, BaseNCodec basedCodec, boolean doEncode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes this output stream and releases any system resources associated with the stream.void
flush()
Flushes this output stream and forces any buffered output bytes to be written out to the stream.private void
flush(boolean propagate)
Flushes this output stream and forces any buffered output bytes to be written out to the stream.void
write(byte[] b, int offset, int len)
Writeslen
bytes from the specifiedb
array starting atoffset
to this output stream.void
write(int i)
Writes the specifiedbyte
to this output stream.
-
-
-
Field Detail
-
doEncode
private final boolean doEncode
-
baseNCodec
private final BaseNCodec baseNCodec
-
singleByte
private final byte[] singleByte
-
context
private final BaseNCodec.Context context
-
-
Constructor Detail
-
BaseNCodecOutputStream
public BaseNCodecOutputStream(java.io.OutputStream out, BaseNCodec basedCodec, boolean doEncode)
-
-
Method Detail
-
write
public void write(int i) throws java.io.IOException
Writes the specifiedbyte
to this output stream.- Overrides:
write
in classjava.io.FilterOutputStream
- Parameters:
i
- source byte- Throws:
java.io.IOException
- if an I/O error occurs.
-
write
public void write(byte[] b, int offset, int len) throws java.io.IOException
Writeslen
bytes from the specifiedb
array starting atoffset
to this output stream.- Overrides:
write
in classjava.io.FilterOutputStream
- Parameters:
b
- source byte arrayoffset
- where to start reading the byteslen
- maximum number of bytes to write- Throws:
java.io.IOException
- if an I/O error occurs.java.lang.NullPointerException
- if the byte array parameter is nulljava.lang.IndexOutOfBoundsException
- if offset, len or buffer size are invalid
-
flush
private void flush(boolean propagate) throws java.io.IOException
Flushes this output stream and forces any buffered output bytes to be written out to the stream. If propagate is true, the wrapped stream will also be flushed.- Parameters:
propagate
- boolean flag to indicate whether the wrapped OutputStream should also be flushed.- Throws:
java.io.IOException
- if an I/O error occurs.
-
flush
public void flush() throws java.io.IOException
Flushes this output stream and forces any buffered output bytes to be written out to the stream.- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
- if an I/O error occurs.
-
close
public void close() throws java.io.IOException
Closes this output stream and releases any system resources associated with the stream.- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
- if an I/O error occurs.
-
-