public class Base64 extends Object
Constructor and Description |
---|
Base64() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
decode(byte[] in)
解码Base64
|
static byte[] |
decode(CharSequence base64)
base64解码
|
static String |
decodeStr(CharSequence source)
base64解码
|
static String |
decodeStr(CharSequence source,
Charset charset)
base64解码
|
static String |
decodeStr(CharSequence source,
String charset)
base64解码
|
static String |
decodeStrGbk(CharSequence source)
base64解码
|
static File |
decodeToFile(CharSequence base64,
File destFile)
base64解码
|
static void |
decodeToStream(CharSequence base64,
OutputStream out,
boolean isCloseOut)
base64解码
|
static String |
encode(byte[] source)
base64编码
|
static byte[] |
encode(byte[] arr,
boolean lineSep)
编码为Base64,非URL安全的
|
static byte[] |
encode(byte[] arr,
boolean isMultiLine,
boolean isUrlSafe)
编码为Base64
如果isMultiLine为 true ,则每76个字符一个换行符,否则在一行显示 |
static String |
encode(CharSequence source)
base64编码
|
static String |
encode(CharSequence source,
Charset charset)
base64编码
|
static String |
encode(CharSequence source,
String charset)
base64编码
|
static String |
encode(File file)
base64编码
|
static String |
encode(InputStream in)
base64编码
|
static String |
encodeStr(byte[] arr,
boolean isMultiLine,
boolean isUrlSafe)
编码为Base64字符串
如果isMultiLine为 true ,则每76个字符一个换行符,否则在一行显示 |
static String |
encodeUrlSafe(byte[] source)
base64编码,URL安全的
|
static byte[] |
encodeUrlSafe(byte[] arr,
boolean lineSep)
Deprecated.
按照RFC2045规范,URL安全的Base64无需换行
|
static String |
encodeUrlSafe(CharSequence source)
base64编码,URL安全
|
static String |
encodeUrlSafe(CharSequence source,
Charset charset)
base64编码,URL安全的
|
static String |
encodeUrlSafe(CharSequence source,
String charset)
Deprecated.
|
static String |
encodeUrlSafe(File file)
base64编码,URL安全的
|
static String |
encodeUrlSafe(InputStream in)
base64编码,URL安全的
|
static String |
encodeWithoutPadding(byte[] source)
base64编码,不进行padding(末尾不会填充'=')
|
static String |
encodeWithoutPadding(CharSequence source,
String charset)
base64编码,不进行padding(末尾不会填充'=')
|
static boolean |
isBase64(byte[] base64Bytes)
检查是否为Base64
|
static boolean |
isBase64(CharSequence base64)
检查是否为Base64
|
public static byte[] encode(byte[] arr, boolean lineSep)
arr
- 被编码的数组lineSep
- 在76个char之后是CRLF还是EOF@Deprecated public static byte[] encodeUrlSafe(byte[] arr, boolean lineSep)
arr
- 被编码的数组lineSep
- 在76个char之后是CRLF还是EOFpublic static String encode(CharSequence source)
source
- 被编码的base64字符串public static String encodeUrlSafe(CharSequence source)
source
- 被编码的base64字符串public static String encode(CharSequence source, String charset)
source
- 被编码的base64字符串charset
- 字符集public static String encodeWithoutPadding(CharSequence source, String charset)
source
- 被编码的base64字符串charset
- 编码@Deprecated public static String encodeUrlSafe(CharSequence source, String charset)
encodeUrlSafe(CharSequence, Charset)
source
- 被编码的base64字符串charset
- 字符集public static String encode(CharSequence source, Charset charset)
source
- 被编码的base64字符串charset
- 字符集public static String encodeUrlSafe(CharSequence source, Charset charset)
source
- 被编码的base64字符串charset
- 字符集public static String encode(byte[] source)
source
- 被编码的base64字符串public static String encodeWithoutPadding(byte[] source)
source
- 被编码的base64字符串public static String encodeUrlSafe(byte[] source)
source
- 被编码的base64字符串public static String encode(InputStream in)
in
- 被编码base64的流(一般为图片流或者文件流)public static String encodeUrlSafe(InputStream in)
in
- 被编码base64的流(一般为图片流或者文件流)public static String encode(File file)
file
- 被编码base64的文件public static String encodeUrlSafe(File file)
file
- 被编码base64的文件public static String encodeStr(byte[] arr, boolean isMultiLine, boolean isUrlSafe)
true
,则每76个字符一个换行符,否则在一行显示arr
- 被编码的数组isMultiLine
- 在76个char之后是CRLF还是EOFisUrlSafe
- 是否使用URL安全字符,一般为false
public static byte[] encode(byte[] arr, boolean isMultiLine, boolean isUrlSafe)
true
,则每76个字符一个换行符,否则在一行显示arr
- 被编码的数组isMultiLine
- 在76个char之后是CRLF还是EOFisUrlSafe
- 是否使用URL安全字符,一般为false
public static String decodeStrGbk(CharSequence source)
source
- 被解码的base64字符串public static String decodeStr(CharSequence source)
source
- 被解码的base64字符串public static String decodeStr(CharSequence source, String charset)
source
- 被解码的base64字符串charset
- 字符集public static String decodeStr(CharSequence source, Charset charset)
source
- 被解码的base64字符串charset
- 字符集public static File decodeToFile(CharSequence base64, File destFile)
base64
- 被解码的base64字符串destFile
- 目标文件public static void decodeToStream(CharSequence base64, OutputStream out, boolean isCloseOut)
base64
- 被解码的base64字符串out
- 写出到的流isCloseOut
- 是否关闭输出流public static byte[] decode(CharSequence base64)
base64
- 被解码的base64字符串public static byte[] decode(byte[] in)
in
- 输入public static boolean isBase64(CharSequence base64)
base64
- Base64的bytespublic static boolean isBase64(byte[] base64Bytes)
base64Bytes
- Base64的bytesCopyright © 2024. All rights reserved.