Here you can find the source of base64Encode(String s)
public static String base64Encode(String s)
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; public class Main { private static final String DEFAULT_CHARSET = "utf-8"; public static String base64Encode(String s) { if (s == null) return null; try {/*from w w w . j a va 2 s . c o m*/ return (new sun.misc.BASE64Encoder()).encode(s.getBytes(DEFAULT_CHARSET)); } catch (UnsupportedEncodingException e) { return null; } } public static String base64Encode(byte[] data) { if (data == null || data.length == 0) return null; return (new sun.misc.BASE64Encoder()).encode(data); } }