public class Base64 extends Object
This class implements section 6.8. Base64 Content-Transfer-Encoding from RFC 2045 Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies by Freed and Borenstein.
The class can be parameterized in the following manner with various constructors:
Since this class operates directly on byte streams, and not character streams, it is hard-coded to only encode/decode character encodings which are compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, UTF-8, etc).
This class is not thread-safe. Each thread should use its own instance.
| 构造器和说明 |
|---|
Base64()
Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode.
|
| 限定符和类型 | 方法和说明 |
|---|---|
static byte[] |
decodeBase64(byte[] base64Data)
Decodes Base64 data into octets.
|
static byte[] |
encodeBase64(byte[] binaryData)
Encodes binary data using the base64 algorithm but does not chunk the output.
|
static byte[] |
encodeBase64(byte[] binaryData,
boolean isChunked,
boolean urlSafe,
int maxResultSize)
Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks.
|
public Base64()
When encoding the line length is 0 (no chunking), and the encoding table is STANDARD_ENCODE_TABLE.
When decoding all variants are supported.
public static byte[] encodeBase64(byte[] binaryData)
binaryData - binary data to encodepublic static byte[] encodeBase64(byte[] binaryData,
boolean isChunked,
boolean urlSafe,
int maxResultSize)
binaryData - Array containing binary data to encode.isChunked - if true this encoder will chunk the base64 output into 76 character blocksurlSafe - if true this encoder will emit - and _ instead of the usual + and /
characters.maxResultSize - The maximum result size to accept.IllegalArgumentException - Thrown when the input array needs an output array bigger than maxResultSizepublic static byte[] decodeBase64(byte[] base64Data)
base64Data - Byte array containing Base64 dataCopyright © 2018–2024 Alibaba Group. All rights reserved.