import sun.misc.BASE64Decoder; import sun.misc.BASE64Encoder; public class BASE64Coding { private static BASE64Encoder encoder = new BASE64Encoder(); private static BASE64Decoder decoder = new BASE64Decoder(); public BASE64Coding() { } public static String encode(String s) { return encoder.encode(s.getBytes()); } public static String decode(String s) { try { byte[] temp = decoder.decodeBuffer(s); return new String(temp); } catch (Exception e) { // handler e.printStackTrace(); return null; } } }