logo

Encode byte array into Base64 format using Base64.encodeBase64() with Apache Commons Codec

Java Code Examples for org.apache.commons.codec.binary.Base64.encodeBase64()

This static method to encode input byte array into a Base64 format.

package simplesolution.dev;

import org.apache.commons.codec.binary.Base64;

public class Base64EncodeBase64Examples {

    public static void main(String... args) {
        String valueToEncode = "https://simplesolution.dev/";
        byte[] encodedBytes = Base64.encodeBase64(valueToEncode.getBytes());
        String encodedString = new String(encodedBytes);
        
        System.out.println("Encode output: ");
        System.out.println(encodedString);
    }
}

Happy Coding 😊