|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcodec.Base64
public class Base64
Encodes and decodes data according to Base64 encoding as described in RFC 1521. Encoded data is broken into lines of 76 charcters each (19 groups of 4 characters which represent 3 bytes of input per group.
The three input bytes are divided into four groups of
six bits each which are encoded according to the
table base64 given below.
| Field Summary | |
|---|---|
private static char[] |
base64
The basic Base64 encoding table. |
private static byte |
F
Marks an entry in the decoding table as an invalid code character. |
private static String |
hex
Used to transform bytes into a hexadecimal string representation - basically a convenience method which facilitates debugging and verification. |
private static byte |
PAD
Marks the pad character '=' in the decoding table. |
private static char |
pad1
If the input is congruent 2 modulo 3 then one pad character is required. |
private static String |
pad2
If the input is congruent 1 modulo 3 then two pad characters are required. |
private static byte[] |
reverse
The table reverse serves to transform
encoded characters back into the corresponding six
bit values efficiently. |
| Constructor Summary | |
|---|---|
private |
Base64()
This class is never instantiated; use the class methods instead. |
| Method Summary | |
|---|---|
static byte[] |
decode(byte[] code)
Decodes a given byte array containing Unicode BASE_LATIN encoded characters with one byte encoding per character. |
static byte[] |
decode(String input)
Decodes a Base64 encoded string into an array of bytes with exactly the length of the encoded data. |
static String |
encode(byte[] input)
Encodes the input array of bytes into a Base64 encoded string with padding if required. |
static String |
toHex(byte[] b)
Encodes a byte array into a hexadecimal string representation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static final char[] base64
private static char pad1
private static String pad2
private static final byte F
private static final byte PAD
private static final byte[] reverse
reverse serves to transform
encoded characters back into the corresponding six
bit values efficiently.
private static final String hex
| Constructor Detail |
|---|
private Base64()
| Method Detail |
|---|
public static String encode(byte[] input)
input - The byte array to be encoded.
public static byte[] decode(String input)
throws CorruptedCodeException
input - The encoded Base64 character String.
CorruptedCodeException - if the Base64 code
contains errors such as a missing character or bad
padding.
public static byte[] decode(byte[] code)
throws CorruptedCodeException
byte[] decode(String).
code - The BASE_LATIN Base64 encoded input with
one byte per character.
CorruptedCodeException - if the decoding process
revealed errors such as bad padding or missing charcters.public static String toHex(byte[] b)
b - The input byte array.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||