public class Base64OutputStream extends OutputStream
Base64OutputStream
is used to write base64 text
in the form of a string through a conventional output stream. This
is provided for convenience so that it is possible to encode and
decode binary data as base64 for implementations that would
normally use a binary format.Base64Encoder
Constructor and Description |
---|
Base64OutputStream()
Constructor for the
Base64OutputStream object. |
Base64OutputStream(int capacity)
Constructor for the
Base64OutputStream object. |
Modifier and Type | Method and Description |
---|---|
void |
close()
This is used to close the stream and encode the buffered bytes
to base64.
|
String |
toString()
This returns the base64 text encoded from the bytes written to
the stream.
|
void |
write(byte[] array,
int offset,
int length)
This method is used to write data as base64 to an internal buffer.
|
void |
write(int octet)
This method is used to write data as base64 to an internal buffer.
|
flush, write
public Base64OutputStream()
Base64OutputStream
object. A
stream created with this constructor uses an initial capacity
of one kilobyte, the capacity is increased as bytes are written.public Base64OutputStream(int capacity)
Base64OutputStream
object. A
stream created with this constructor can have an initial capacity
specified. Typically it is a good rule of thumb to use a capacity
that is just over an additional third of the source binary data.capacity
- this is the initial capacity of the bufferpublic void write(int octet) throws IOException
toString
method can be used to acquire the text
encoded from the written binary data.write
in class OutputStream
octet
- the octet to encode in to the internal bufferIOException
public void write(byte[] array, int offset, int length) throws IOException
toString
method can be used to acquire the text
encoded from the written binary data.write
in class OutputStream
array
- the octets to encode to the internal bufferoffset
- this is the offset in the array to encode fromlength
- this is the number of bytes to be encodedIOException
public void close() throws IOException
toString
method can
be used to acquire the base64 encoded text.close
in interface Closeable
close
in interface AutoCloseable
close
in class OutputStream
IOException
Copyright © 2024. All rights reserved.