Here you can find the source of encodeUtf8AsBase64(String data)
public static String encodeUtf8AsBase64(String data)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import com.google.common.io.BaseEncoding; public class Main { public static final String UTF_8 = "UTF-8"; public static String encodeUtf8AsBase64(String data) { return encodeAsBase64(decodeAsUtf8(data)); }/*from www. j a v a2s. com*/ public static String encodeAsBase64(byte[] bytes) { return new String(BaseEncoding.base64().encode(bytes)); } public static byte[] decodeAsUtf8(String data) { try { return data.getBytes(UTF_8); } catch (UnsupportedEncodingException e) { throw new RuntimeException(e); } } }