Java tutorial
//package com.java2s; //License from project: Open Source License import org.apache.commons.codec.binary.Base64; public class Main { static String encodeBase64String(byte[] binaryData) { String encodedString = Base64.encodeBase64String(binaryData); if (encodedString.endsWith("\r\n")) { encodedString = encodedString.substring(0, encodedString.length() - 2); } return encodedString; } }