Here you can find the source of base64Encode(String data)
Parameter | Description |
---|---|
data | the string to encode |
Parameter | Description |
---|---|
UnsupportedEncodingException | an exception |
public static String base64Encode(String data) throws UnsupportedEncodingException
//package com.java2s; //License from project: Apache License import java.io.UnsupportedEncodingException; import javax.xml.bind.DatatypeConverter; public class Main { /**//from w ww.j ava2 s.co m * Encode the given string with Base64 * @param data the string to encode * @return the encoded string * @throws UnsupportedEncodingException */ public static String base64Encode(String data) throws UnsupportedEncodingException { return DatatypeConverter.printBase64Binary(data.getBytes("UTF-8")); } }