Here you can find the source of toBase64Encoded(String unencoded)
public static String toBase64Encoded(String unencoded)
//package com.java2s; /******************************************************************************* * Copyright (c) 2012-2016 Red Hat, Inc. * Distributed under license by Red Hat, Inc. All rights reserved. * This program is 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 * /*from w w w .j a v a 2 s. c o m*/ * Contributors: * Red Hat, Inc. - initial API and implementation ******************************************************************************/ import javax.xml.bind.DatatypeConverter; public class Main { public static String toBase64Encoded(String unencoded) { if (unencoded == null) { return null; } else if (unencoded.getBytes().length == 0) { return new String(); } return DatatypeConverter.printBase64Binary(unencoded.getBytes()); } }