public class Base64 extends Object
当前BASE64引擎代码来源JDK1.8本身,使其能在JDK1.7上使用,并且提供了快捷工具类。
| 限定符和类型 | 类和说明 |
|---|---|
static class |
Base64.Decoder
This class implements a decoder for decoding byte data using the
Base64 encoding scheme as specified in RFC 4648 and RFC 2045.
|
static class |
Base64.Encoder
This class implements an encoder for encoding byte data using
the Base64 encoding scheme as specified in RFC 4648 and RFC 2045.
|
| 限定符和类型 | 方法和说明 |
|---|---|
static byte[] |
decode(String base64Data)
标准的BASE64解码
|
static byte[] |
decode(String base64Data,
boolean isUrlSafe)
标准的BASE64解码
|
static String |
decode2String(String base64Data)
标准的BASE64解码
|
static String |
decode2String(String base64Data,
boolean isUrlSafe)
标准的BASE64解码
|
static String |
encode(byte[] data)
标准的BASE64编码
|
static String |
encode(byte[] data,
boolean isUrlSafe)
BASE64编码
|
static String |
encode(String data)
标准的BASE64编码
|
static String |
encode(String data,
boolean isUrlSafe)
标准的BASE64编码
|
static String |
encode(String data,
Charset encoding)
标准的BASE64编码
|
static String |
encode(String data,
Charset encoding,
boolean isUrlSafe)
标准的BASE64编码
|
static Base64.Decoder |
getDecoder()
Returns a
Base64.Decoder that decodes using the
Basic type base64 encoding scheme. |
static Base64.Encoder |
getEncoder()
Returns a
Base64.Encoder that encodes using the
Basic type base64 encoding scheme. |
static Base64.Decoder |
getMimeDecoder()
Returns a
Base64.Decoder that decodes using the
MIME type base64 decoding scheme. |
static Base64.Encoder |
getMimeEncoder()
Returns a
Base64.Encoder that encodes using the
MIME type base64 encoding scheme. |
static Base64.Encoder |
getMimeEncoder(int lineLength,
byte[] lineSeparator)
Returns a
Base64.Encoder that encodes using the
MIME type base64 encoding scheme
with specified line length and line separators. |
static Base64.Decoder |
getUrlDecoder()
Returns a
Base64.Decoder that decodes using the
URL and Filename safe type base64
encoding scheme. |
static Base64.Encoder |
getUrlEncoder()
Returns a
Base64.Encoder that encodes using the
URL and Filename safe type base64
encoding scheme. |
public static String encode(byte[] data)
data - 待BASE64编码的字节数组public static String encode(byte[] data, boolean isUrlSafe)
data - 待BASE64编码的字节数组isUrlSafe - 为true则URL安全字符,否则为标准BASE64字符public static String encode(String data)
data - 待BASE64编码的字符串public static String encode(String data, boolean isUrlSafe)
data - 待BASE64编码的字符串isUrlSafe - 为true则URL安全字符,否则为标准BASE64字符public static String encode(String data, Charset encoding)
data - 待BASE64编码的字符串encoding - 原始数据的编码,为空时采用UTF-8编码public static String encode(String data, Charset encoding, boolean isUrlSafe)
data - 待BASE64编码的字符串encoding - 原始数据的编码,为空时采用UTF-8编码isUrlSafe - 为true则URL安全字符,否则为标准BASE64字符public static byte[] decode(String base64Data)
base64Data - 已经编码过的字符串public static byte[] decode(String base64Data, boolean isUrlSafe)
base64Data - 已经编码过的字符串isUrlSafe - 为true则URL安全字符,否则为标准BASE64字符public static String decode2String(String base64Data)
base64Data - 已经编码过的字符串public static String decode2String(String base64Data, boolean isUrlSafe)
base64Data - 已经编码过的字符串isUrlSafe - 原始数据的编码,为空时采用UTF-8编码public static Base64.Encoder getEncoder()
Base64.Encoder that encodes using the
Basic type base64 encoding scheme.public static Base64.Encoder getUrlEncoder()
Base64.Encoder that encodes using the
URL and Filename safe type base64
encoding scheme.public static Base64.Encoder getMimeEncoder()
Base64.Encoder that encodes using the
MIME type base64 encoding scheme.public static Base64.Encoder getMimeEncoder(int lineLength, byte[] lineSeparator)
Base64.Encoder that encodes using the
MIME type base64 encoding scheme
with specified line length and line separators.lineLength - the length of each output line (rounded down to nearest multiple
of 4). If lineLength <= 0 the output will not be separated
in lineslineSeparator - the line separator for each output lineIllegalArgumentException - if lineSeparator includes any
character of "The Base64 Alphabet" as specified in Table 1 of
RFC 2045.public static Base64.Decoder getDecoder()
Base64.Decoder that decodes using the
Basic type base64 encoding scheme.public static Base64.Decoder getUrlDecoder()
Base64.Decoder that decodes using the
URL and Filename safe type base64
encoding scheme.public static Base64.Decoder getMimeDecoder()
Base64.Decoder that decodes using the
MIME type base64 decoding scheme.Copyright © 2017. All rights reserved.