/** Encodes a raw byte array into a BASE64 <code>String</code> representation i accordance with RFC 2045. * @param sArr The bytes to convert. If <code>null</code> or length 0 an empty array will be returned. * @param lineSep Optional "\r\n" after 76 characters, unless end of file.<br> * No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a * little faster. * @return A BASE64 encoded array. Never <code>null</code>. */ public final static String encodeToString(byte[] sArr, boolean lineSep) { // Reuse char[] since we can't create a String incrementally anyway and StringBuffer/Builder would be slower. return new String(encodeToChar(sArr, lineSep)); }
/** Encodes a raw byte array into a BASE64 <code>String</code> representation i accordance with RFC 2045. * @param sArr The bytes to convert. If <code>null</code> or length 0 an empty array will be returned. * @param lineSep Optional "\r\n" after 76 characters, unless end of file.<br> * No line separator will be in breach of RFC 2045 which specifies max 76 per line but will be a * little faster. * @return A BASE64 encoded array. Never <code>null</code>. */ public final static String encodeToString(byte[] sArr, boolean lineSep) { // Reuse char[] since we can't create a String incrementally anyway and StringBuffer/Builder would be slower. return new String(encodeToChar(sArr, lineSep)); }