Java Utililty Methods XML Base64 Encode Decode

List of utility methods to do XML Base64 Encode Decode

Description

The list of methods to do XML Base64 Encode Decode are organized into topic(s).

Method

StringtoB64(byte[] bytes)
to B
return javax.xml.bind.DatatypeConverter.printBase64Binary(bytes);
StringtoBase10(String base64)
to Base
return new String(DatatypeConverter.parseBase64Binary(base64.trim().substring("Basic ".length()).trim()));
StringtoBase64(byte[] array)
Converts a byte array into a hexadecimal string.
return DatatypeConverter.printBase64Binary(array);
StringtoBase64Encoded(String unencoded)
to Base Encoded
if (unencoded == null) {
    return null;
} else if (unencoded.getBytes().length == 0) {
    return new String();
return DatatypeConverter.printBase64Binary(unencoded.getBytes());
StringtoBase64String(final byte[] data)
Converts the specified data to base64 encoded string.
return javax.xml.bind.DatatypeConverter.printBase64Binary(data);
StringtoSafePathBase64(byte[] value)
to Safe Path Base
return toBase64(value).replace('/', '-');
byte[]urlSafeBase64Decode(String in)
url Safe Base Decode
in = in.replace('-', '+');
in = in.replace('_', '/');
return DatatypeConverter.parseBase64Binary(in);