public class Base64Encoder extends java.lang.Object implements StringCodec
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.
Constructor and Description |
---|
Base64Encoder()
Constructs a Base64Encoder.
|
Base64Encoder(boolean lineBreaks)
Constructs a Base64Encoder.
|
Modifier and Type | Method and Description |
---|---|
byte[] |
decode(java.lang.String input)
Decode the provided encoded string.
|
java.lang.String |
encode(byte[] input)
Encode the provided data.
|
public Base64Encoder()
The encoder will not insert any line breaks.
public Base64Encoder(boolean lineBreaks)
lineBreaks
- flag to insert line breakspublic java.lang.String encode(byte[] input)
StringCodec
encode
in interface StringCodec
input
- the data to encodepublic byte[] decode(java.lang.String input)
StringCodec
decode
in interface StringCodec
input
- the encoded stringCopyright © 2004–2023 XStream. All rights reserved.