Here you can find the source of encodeBase64(String stringValue)
public static String encodeBase64(String stringValue) throws NoSuchAlgorithmException, UnsupportedEncodingException
//package com.java2s; /******************************************************************************* * Copyright (c) 2011, 2016 Eurotech and/or its affiliates and others * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:// w w w. j av a 2 s .com * Eurotech - initial API and implementation * *******************************************************************************/ import java.io.UnsupportedEncodingException; import java.security.NoSuchAlgorithmException; import javax.xml.bind.DatatypeConverter; public class Main { public static String encodeBase64(String stringValue) throws NoSuchAlgorithmException, UnsupportedEncodingException { byte[] bytesValue = stringValue.getBytes("UTF-8"); String encodedValue = DatatypeConverter.printBase64Binary(bytesValue); return encodedValue; } }