Despite there being a gazillion other Base64 implementations out there, this has been written as part of XStream as it forms a core part but is too trivial to warrant an extra dependency. Recent Java Runtimes (since Java 6) provide an own Base64 codec though.
By default it will not insert line breaks to support Base64 values also as attribute values. However, the standard as described in RFC 1521, section 5.2 requires line breaks, allowing other Base64 tools to manipulate the data. You can configure the Base64Encoder to be RFC compliant.
| Modifier and Type | Field and Description |
|---|---|
| private final boolean | |
| private static final int[] | |
| private static final char[] |
| Access | Constructor and Description |
|---|---|
| public | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv int | |
| public byte[] | decode(final String
the encoded string input)Implements com. |
| public String | encode(final byte[]
the data to encode input)Implements com. |
| private int |
| lineBreaks | back to summary |
|---|---|
| private final boolean lineBreaks | |
| REVERSE_MAPPING | back to summary |
|---|---|
| private static final int[] REVERSE_MAPPING | |
| SIXTY_FOUR_CHARS | back to summary |
|---|---|
| private static final char[] SIXTY_FOUR_CHARS | |
| Base64Encoder | back to summary |
|---|---|
| public Base64Encoder() Constructs a Base64Encoder. The encoder will not insert any line breaks.
| |
| Base64Encoder | back to summary |
|---|---|
| public Base64Encoder(final boolean lineBreaks) Constructs a Base64Encoder.
| |
| computeResultingStringSize | back to summary |
|---|---|
| pack-priv int computeResultingStringSize(final byte[] input) | |
| decode | back to summary |
|---|---|
| public byte[] decode(final String input) Implements com. Doc from com. Decode the provided encoded string.
| |
| encode | back to summary |
|---|---|
| public String encode(final byte[] input) Implements com. Doc from com. Encode the provided data.
| |
| mapCharToInt | back to summary |
|---|---|
| private int mapCharToInt(final Reader input) throws IOException | |