Java XML Base64 Encode Decode base64Encode(String data)

Here you can find the source of base64Encode(String data)

Description

Encode the given string with Base64

License

Apache License

Parameter

Parameter Description
data the string to encode

Exception

Parameter Description
UnsupportedEncodingException an exception

Return

the encoded string

Declaration

public static String base64Encode(String data) throws UnsupportedEncodingException 

Method Source Code


//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"));
    }
}

Related

  1. base64en(String string)
  2. base64Encode(byte[] bytes)
  3. base64Encode(byte[] bytes)
  4. base64Encode(byte[] bytes)
  5. base64encode(byte[] bytes, boolean pad)
  6. base64EncodeBasicCredentials(String username, String password)
  7. base64FromBinary(byte[] value)
  8. base64FromString(String value)
  9. base64ToByte(String data)