logo

Encode a String into Base64 format using Base64.encodeToString() with Apache Commons Codec

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

This method to encode input String into a Base64 format String.

package simplesolution.dev;

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

public class Base64EncodeToStringExamples {

    public static void main(String... args) {
        Base64 base64 = new Base64();
        String valueToEncode = "https://simplesolution.dev/";
        String encodedString = base64.encodeToString(valueToEncode.getBytes());

        System.out.println("Encode output: ");
        System.out.println(encodedString);
    }
}

Happy Coding 😊