Package com.stimulsoft.lib.base64
Class StiBase64DecoderUtil
java.lang.Object
com.stimulsoft.lib.base64.StiBase64DecoderUtil
Class decodes a Base64 encoded data back into the original byte representation and writes to
output stream.
-
Constructor Summary
ConstructorsConstructorDescriptionStiBase64DecoderUtil(OutputStream stream) Construct a Base64Decoder waiting on calls to its translate() method. -
Method Summary
Modifier and TypeMethodDescriptionstatic byte[]decode(byte[] data) Decode given byte array into a decoded byte array.static byte[]decode(byte[] data, int begin, int end) Decode given byte array into a decoded byte array.static voiddecode(InputStream input, OutputStream out) Decode bytes from input stream and write decoded bytes to output stream.static voiddecode(InputStream input, OutputStream out, long count) Decode bytes from input stream and write decoded bytes to output stream.static byte[]voidflush()Writes all decoded octets.translate(byte[] bytes) Translate every base64 character from given byte array into a sextet byte value by using above translation array.translate(byte[] bytes, int begin, int end) Translate every base64 character from given byte array into a sextet byte value by using above translation array.
-
Constructor Details
-
StiBase64DecoderUtil
Construct a Base64Decoder waiting on calls to its translate() method. Base64Decoder must be flushed to write internally buffered data to output stream.
-
-
Method Details
-
decode
Decode bytes from input stream and write decoded bytes to output stream.- Parameters:
input- input streamout- output stream- Throws:
IOException- if an I/O error occurs
-
decode
Decode bytes from input stream and write decoded bytes to output stream.- Parameters:
input- input streamout- output streamcount- count of bytes to read and decode; -1 for all available bytes- Throws:
IOException- if an I/O error occurs
-
decode
-
decode
public static byte[] decode(byte[] data) Decode given byte array into a decoded byte array.- Parameters:
data- Base64 byte array to be decoded.- Returns:
- All decoded octets as byte array.
-
decode
public static byte[] decode(byte[] data, int begin, int end) Decode given byte array into a decoded byte array.- Parameters:
data- Base64 byte array to be decodedbegin- index of the first byte to start fromend- index after the last byte- Returns:
- All decoded octets as byte array.
-
translate
Translate every base64 character from given byte array into a sextet byte value by using above translation array. The sextets are then shifted into an buffer until the buffer contains 4 sextets which are then decoded into 3 octets. The translate and decode process is continued until all bytes of given byte array are evaluated. If there are remaining sextets in the buffer they also will be converted into octets at the end. All the converted octets are written to the output stream.- Parameters:
bytes- the byte array to be decoded- Returns:
- Base64Decoder
- Throws:
IOException- if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
-
translate
Translate every base64 character from given byte array into a sextet byte value by using above translation array. The sextets are then shifted into an buffer until the buffer contains 4 sextets which are then decoded into 3 octets. The translate and decode process is continued until all bytes of given byte array are evaluated. If there are remaining sextets in the buffer they also will be converted into octets at the end. All the converted octets are written to the output stream.- Parameters:
bytes- the byte array to be decodedbegin- index of the first byte to start fromend- index after the last byte- Returns:
- Base64Decoder
- Throws:
IOException- if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
-
flush
Writes all decoded octets.- Throws:
IOException- if an I/O error occurs. In particular, an IOException may be thrown if the output stream has been closed.
-