Java Utililty Methods Byte Array to Base64

List of utility methods to do Byte Array to Base64

Description

The list of methods to do Byte Array to Base64 are organized into topic(s).

Method

StringbyteArrayToBase64(byte[] a)
Translates the specified byte array into a Base64 string as per Preferences.put(byte[]).
return byteArrayToBase64(a, false);
StringbytesToBase64(byte[] bytes)
bytes To Base
char base64[] = new char[bytes.length];
for (int i = 0; i < bytes.length; i++) {
    base64[i] = sBitChars[bytes[i]];
return new String(base64);
StringbytesToBase64(byte[] bytes, int length)
Converts a maximum of three bytes to 4 Base64 characters
String result = "";
if (length == 3) {
    result += bitsToBase64((byte) ((bytes[0] & 0xFC) >> 2));
    result += bitsToBase64((byte) ((bytes[0] & 0x03) << 4 | (bytes[1] & 0xF0) >> 4));
    result += bitsToBase64((byte) ((bytes[1] & 0x0F) << 2 | (bytes[2] & 0xC0) >> 6));
    result += bitsToBase64((byte) (bytes[2] & 0x3F));
if (length == 2) {
...
StringbyteToBase64(byte[] data)
From a byte[] returns a base 64 representation
return Base64.getEncoder().encodeToString(data);