Base64Encode.java Source code

Java tutorial

Introduction

Here is the source code for Base64Encode.java

Source

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

import java.util.Arrays;

public class Base64Encode {
    public static void main(String[] args) {
        String hello = "Hello World";

        byte[] encoded = Base64.encodeBase64(hello.getBytes());

        System.out.println(Arrays.toString(encoded));

        String encodedString = new String(encoded);
        System.out.println(hello + " = " + encodedString);
    }
}