Class Base64OutputStream
java.lang.Object
java.io.OutputStream
org.simpleframework.common.encode.Base64OutputStream
- All Implemented Interfaces:
Closeable, Flushable, AutoCloseable
The
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.- See Also:
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionConstructor for theBase64OutputStreamobject.Base64OutputStream(int capacity) Constructor for theBase64OutputStreamobject. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()This is used to close the stream and encode the buffered bytes to base64.private voidexpand(int capacity) This will expand the size of the internal buffer.toString()This returns the base64 text encoded from the bytes written to the stream.voidwrite(byte[] array, int offset, int length) This method is used to write data as base64 to an internal buffer.voidwrite(int octet) This method is used to write data as base64 to an internal buffer.Methods inherited from class OutputStream
flush, nullOutputStream, write
-
Field Details
-
encoded
private char[] encoded -
buffer
private byte[] buffer -
temp
private byte[] temp -
count
private int count
-
-
Constructor Details
-
Base64OutputStream
public Base64OutputStream()Constructor for theBase64OutputStreamobject. A stream created with this constructor uses an initial capacity of one kilobyte, the capacity is increased as bytes are written. -
Base64OutputStream
public Base64OutputStream(int capacity) Constructor for theBase64OutputStreamobject. 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.- Parameters:
capacity- this is the initial capacity of the buffer
-
-
Method Details
-
write
This method is used to write data as base64 to an internal buffer. ThetoStringmethod can be used to acquire the text encoded from the written binary data.- Specified by:
writein classOutputStream- Parameters:
octet- the octet to encode in to the internal buffer- Throws:
IOException
-
write
This method is used to write data as base64 to an internal buffer. ThetoStringmethod can be used to acquire the text encoded from the written binary data.- Overrides:
writein classOutputStream- Parameters:
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 encoded- Throws:
IOException
-
expand
This will expand the size of the internal buffer. To allow for a variable length number of bytes to be written the internal buffer can grow as demand exceeds space available.- Parameters:
capacity- this is the minimum capacity required- Throws:
IOException
-
close
This is used to close the stream and encode the buffered bytes to base64. Once this method is invoked no further data can be encoded with the stream. ThetoStringmethod can be used to acquire the base64 encoded text.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classOutputStream- Throws:
IOException
-
toString
-