Base64 converter class. This code is not a complete MIME encoder;
it simply converts binary data to base64 data and back.
Note CharBase64 is a GWT-compatible implementation of this class.
public class Base64
Field Summary
| Modifier and Type | Field and Description |
|---|---|
public static final | DECODESpecify decoding (value is false). |
public static final | ENCODESpecify encoding (value is true). |
Method Summary
| Modifier and Type | Method and Description |
|---|---|
public static byte | decode(String s) Decodes data from Base64 notation. |
public static byte | decode(byte[] source) Decodes Base64 content in byte array format and returns
the decoded byte array. |
public static byte | decode(byte[] source, int off, int len) Decodes Base64 content in byte array format and returns
the decoded byte array. |
public static byte | decode(byte[] source, int off, int len, byte[] decodabet) Decodes Base64 content using the supplied decodabet and returns
the decoded byte array. |
public static byte | decodeWebSafe(String s) Decodes data from web safe Base64 notation. |
public static byte | decodeWebSafe(byte[] source) Decodes web safe Base64 content in byte array format and returns
the decoded data. |
public static byte | decodeWebSafe(byte[] source, int off, int len) Decodes web safe Base64 content in byte array format and returns
the decoded byte array. |
public static String | encode(byte[] source) Encodes a byte array into Base64 notation. |
public static String | encode(byte[] source, int off, int len, byte[] alphabet, boolean doPadding) Encodes a byte array into Base64 notation. |
public static byte | encode(byte[] source, int off, int len, byte[] alphabet, int maxLineLength) Encodes a byte array into Base64 notation. |
public static String | encodeWebSafe(byte[] source, boolean doPadding) Encodes a byte array into web safe Base64 notation. |
Methods inherited from java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitField Detail
| DECODE |
|---|
public static final DECODE Specify decoding (value is false). |
| ENCODE |
|---|
public static final ENCODE Specify encoding (value is true). |
Method Detail
| decode | ||
|---|---|---|
public static byte decode(
String s
)Decodes data from Base64 notation. Parameters:
Returns:
the decoded data |
| decode | ||
|---|---|---|
public static byte decode(
byte[] source
)Decodes Base64 content in byte array format and returns
the decoded byte array. Parameters:
Returns:
decoded data Throws:
|
| decode | ||||||
|---|---|---|---|---|---|---|
public static byte decode(
byte[] source,
int off,
int len
)Decodes Base64 content in byte array format and returns
the decoded byte array. Parameters:
Returns:
decoded data Throws:
|
| decode | ||||||||
|---|---|---|---|---|---|---|---|---|
public static byte decode(
byte[] source,
int off,
int len,
byte[] decodabet
)Decodes Base64 content using the supplied decodabet and returns
the decoded byte array. Parameters:
Returns:
decoded data |
| decodeWebSafe | ||
|---|---|---|
public static byte decodeWebSafe(
String s
)Decodes data from web safe Base64 notation.
Web safe encoding uses '-' instead of '+', '_' instead of '/' Parameters:
Returns:
the decoded data |
| decodeWebSafe | ||
|---|---|---|
public static byte decodeWebSafe(
byte[] source
)Decodes web safe Base64 content in byte array format and returns
the decoded data.
Web safe encoding uses '-' instead of '+', '_' instead of '/' Parameters:
Returns:
the decoded data |
| decodeWebSafe | ||||||
|---|---|---|---|---|---|---|
public static byte decodeWebSafe(
byte[] source,
int off,
int len
)Decodes web safe Base64 content in byte array format and returns
the decoded byte array.
Web safe encoding uses '-' instead of '+', '_' instead of '/' Parameters:
Returns:
decoded data |
| encode | ||
|---|---|---|
public static String encode(
byte[] source
)Encodes a byte array into Base64 notation.
Equivalent to calling
encodeBytes(source, 0, source.length) Parameters:
|
| encode | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
public static String encode(
byte[] source,
int off,
int len,
byte[] alphabet,
boolean doPadding
)Encodes a byte array into Base64 notation. Parameters:
|
| encode | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|
public static byte encode(
byte[] source,
int off,
int len,
byte[] alphabet,
int maxLineLength
)Encodes a byte array into Base64 notation. Parameters:
Returns:
the BASE64-encoded byte array |
| encodeWebSafe | ||||
|---|---|---|---|---|
public static String encodeWebSafe(
byte[] source,
boolean doPadding
)Encodes a byte array into web safe Base64 notation. Parameters:
|