public abstract class Base64Utils
extends java.lang.Object
Adapts to Java 8's Base64
in a convenience fashion.
Base64
Modifier and Type | Field and Description |
---|---|
private static java.nio.charset.Charset |
DEFAULT_CHARSET |
Constructor and Description |
---|
Base64Utils() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
decode(byte[] src)
Base64-decode the given byte array.
|
static byte[] |
decodeFromString(java.lang.String src)
Base64-decode the given byte array from an UTF-8 String.
|
static byte[] |
decodeFromUrlSafeString(java.lang.String src)
Base64-decode the given byte array from an UTF-8 String using the RFC 4648
"URL and Filename Safe Alphabet".
|
static byte[] |
decodeUrlSafe(byte[] src)
Base64-decode the given byte array using the RFC 4648
"URL and Filename Safe Alphabet".
|
static byte[] |
encode(byte[] src)
Base64-encode the given byte array.
|
static java.lang.String |
encodeToString(byte[] src)
Base64-encode the given byte array to a String.
|
static java.lang.String |
encodeToUrlSafeString(byte[] src)
Base64-encode the given byte array to a String using the RFC 4648
"URL and Filename Safe Alphabet".
|
static byte[] |
encodeUrlSafe(byte[] src)
Base64-encode the given byte array using the RFC 4648
"URL and Filename Safe Alphabet".
|
public static byte[] encode(byte[] src)
src
- the original byte arrayjava.lang.IllegalStateException
- if Base64 encoding between byte arrays is not
supported, i.e. neither Java 8 nor Apache Commons Codec is present at runtimepublic static byte[] decode(byte[] src)
src
- the encoded byte arrayjava.lang.IllegalStateException
- if Base64 encoding between byte arrays is not
supported, i.e. neither Java 8 nor Apache Commons Codec is present at runtimepublic static byte[] encodeUrlSafe(byte[] src)
src
- the original byte arrayjava.lang.IllegalStateException
- if Base64 encoding between byte arrays is not
supported, i.e. neither Java 8 nor Apache Commons Codec is present at runtime@Nullable public static byte[] decodeUrlSafe(@Nullable byte[] src)
src
- the encoded byte arrayjava.lang.IllegalStateException
- if Base64 encoding between byte arrays is not
supported, i.e. neither Java 8 nor Apache Commons Codec is present at runtimepublic static java.lang.String encodeToString(byte[] src)
src
- the original byte array (may be null
)public static byte[] decodeFromString(java.lang.String src)
src
- the encoded UTF-8 String@Nullable public static java.lang.String encodeToUrlSafeString(byte[] src)
src
- the original byte arrayjava.lang.IllegalStateException
- if Base64 encoding between byte arrays is not
supported, i.e. neither Java 8 nor Apache Commons Codec is present at runtime@Nullable public static byte[] decodeFromUrlSafeString(java.lang.String src)
src
- the encoded UTF-8 Stringjava.lang.IllegalStateException
- if Base64 encoding between byte arrays is not
supported, i.e. neither Java 8 nor Apache Commons Codec is present at runtime