Most visited

Recently visited

Added in API level 8

Base64

public class Base64
extends Object

java.lang.Object
    android.util.Base64


用于编码和解码二进制数据的Base64表示的实用程序。 请参阅RFC 20453548

摘要(Summary)

常量(Constants)

int CRLF

用于指示行的编码器标志位应该用CRLF对而不仅仅是LF来终止。

int DEFAULT

编码器/解码器标志的默认值。

int NO_CLOSE

传递给 Base64OutputStream标志表明它不应该关闭当它自己关闭时它所包装的输出流。

int NO_PADDING

编码器标志位在输出结束时省略填充'='字符(如果有的话)。

int NO_WRAP

编码器标志位省略所有行终止符(即,输出将位于一条长线上)。

int URL_SAFE

编码器/解码器标志位指示使用Base64的“URL和文件名安全”变体(请参阅RFC 3548第4节),其中使用 -_来代替 +/

公共方法(Public methods)

static byte[] decode(String str, int flags)

在输入中解码Base64编码的数据并将数据返回到新的字节数组中。

static byte[] decode(byte[] input, int flags)

在输入中解码Base64编码的数据并将数据返回到新的字节数组中。

static byte[] decode(byte[] input, int offset, int len, int flags)

在输入中解码Base64编码的数据并将数据返回到新的字节数组中。

static byte[] encode(byte[] input, int flags)

对给定数据进行Base64编码并返回一个新分配的字节[]和结果。

static byte[] encode(byte[] input, int offset, int len, int flags)

对给定数据进行Base64编码并返回一个新分配的字节[]和结果。

static String encodeToString(byte[] input, int offset, int len, int flags)

Base64对给定的数据进行编码并返回一个新分配的字符串和结果。

static String encodeToString(byte[] input, int flags)

Base64对给定的数据进行编码并返回一个新分配的字符串和结果。

继承方法(Inherited methods)

From class java.lang.Object

常量(Constants)

CRLF

Added in API level 8
int CRLF

用于指示行的编码器标志位应该用CRLF对而不仅仅是LF来终止。 如果指定了NO_WRAPNO_WRAP

常量值:4(0x00000004)

DEFAULT

Added in API level 8
int DEFAULT

编码器/解码器标志的默认值。

常量值:0(0x00000000)

NO_CLOSE

Added in API level 8
int NO_CLOSE

传递给 Base64OutputStream标志表明它不应该关闭当它自己关闭时正在包装的输出流。

常量值:16(0x00000010)

NO_PADDING

Added in API level 8
int NO_PADDING

编码器标志位在输出结束时省略填充'='字符(如果有的话)。

常数值:1(0x00000001)

NO_WRAP

Added in API level 8
int NO_WRAP

编码器标志位省略所有行终止符(即,输出将位于一条长线上)。

常量值:2(0x00000002)

URL_SAFE

Added in API level 8
int URL_SAFE

编码器/解码器标志位指示使用Base64的“URL和文件名安全”变体(请参阅RFC 3548第4节),其中使用 -_代替 +/

常量值:8(0x00000008)

公共方法(Public methods)

decode

Added in API level 8
byte[] decode (String str, 
                int flags)

在输入中解码Base64编码的数据并将数据返回到新的字节数组中。

最后的填充'='字符被认为是可选的,但是如果存在的话,必须有正确的数字。

参数(Parameters)
str String: the input String to decode, which is converted to bytes using the default charset
flags int: controls certain features of the decoded output. Pass DEFAULT to decode standard Base64.
返回(Returns)
byte[]
抛出异常(Throws)
IllegalArgumentException if the input contains incorrect padding

decode

Added in API level 8
byte[] decode (byte[] input, 
                int flags)

在输入中解码Base64编码的数据并将数据返回到新的字节数组中。

最后的填充'='字符被认为是可选的,但是如果存在的话,必须有正确的数字。

参数(Parameters)
input byte: the input array to decode
flags int: controls certain features of the decoded output. Pass DEFAULT to decode standard Base64.
返回(Returns)
byte[]
抛出异常(Throws)
IllegalArgumentException if the input contains incorrect padding

decode

Added in API level 8
byte[] decode (byte[] input, 
                int offset, 
                int len, 
                int flags)

在输入中解码Base64编码的数据并将数据返回到新的字节数组中。

最后的填充'='字符被认为是可选的,但是如果存在的话,必须有正确的数字。

参数(Parameters)
input byte: the data to decode
offset int: the position within the input array at which to start
len int: the number of bytes of input to decode
flags int: controls certain features of the decoded output. Pass DEFAULT to decode standard Base64.
返回(Returns)
byte[]
抛出异常(Throws)
IllegalArgumentException if the input contains incorrect padding

encode

Added in API level 8
byte[] encode (byte[] input, 
                int flags)

对给定数据进行Base64编码并返回一个新分配的字节[]和结果。

参数(Parameters)
input byte: the data to encode
flags int: controls certain features of the encoded output. Passing DEFAULT results in output that adheres to RFC 2045.
返回(Returns)
byte[]

encode

Added in API level 8
byte[] encode (byte[] input, 
                int offset, 
                int len, 
                int flags)

对给定数据进行Base64编码并返回一个新分配的字节[]和结果。

参数(Parameters)
input byte: the data to encode
offset int: the position within the input array at which to start
len int: the number of bytes of input to encode
flags int: controls certain features of the encoded output. Passing DEFAULT results in output that adheres to RFC 2045.
返回(Returns)
byte[]

encodeToString

Added in API level 8
String encodeToString (byte[] input, 
                int offset, 
                int len, 
                int flags)

Base64对给定的数据进行编码并返回一个新分配的字符串和结果。

参数(Parameters)
input byte: the data to encode
offset int: the position within the input array at which to start
len int: the number of bytes of input to encode
flags int: controls certain features of the encoded output. Passing DEFAULT results in output that adheres to RFC 2045.
返回(Returns)
String

encodeToString

Added in API level 8
String encodeToString (byte[] input, 
                int flags)

Base64对给定的数据进行编码并返回一个新分配的字符串和结果。

参数(Parameters)
input byte: the data to encode
flags int: controls certain features of the encoded output. Passing DEFAULT results in output that adheres to RFC 2045.
返回(Returns)
String

Hooray!