return encodeBytes(source, 0, source.length, options);
return encodeBytes(source, 0, source.length, options);
/** * Encodes a byte array into Base64 notation. Does not GZip-compress data. * * @param source The data to convert * @return The data in Base64-encoded form * @throws NullPointerException if source array is null * @since 1.4 */ public static String encodeBytes(final byte[] source) { // Since we're not going to have the GZIP encoding turned on, // we're not going to have an java.io.IOException thrown, so // we should not force the user to have to catch it. String encoded = null; try { encoded = encodeBytes(source, 0, source.length, NO_OPTIONS); } catch (final java.io.IOException ex) { assert false : ex.getMessage(); } // end catch assert encoded != null; return encoded; } // end encodeBytes
/** * Encodes a byte array into Base64 notation. Does not GZip-compress data. * * @param source The data to convert * @return The data in Base64-encoded form * @throws NullPointerException if source array is null * @since 1.4 */ public static String encodeBytes(final byte[] source) { // Since we're not going to have the GZIP encoding turned on, // we're not going to have an java.io.IOException thrown, so // we should not force the user to have to catch it. String encoded = null; try { encoded = encodeBytes(source, 0, source.length, NO_OPTIONS); } catch (final java.io.IOException ex) { assert false : ex.getMessage(); } // end catch assert encoded != null; return encoded; } // end encodeBytes
/** * Encodes a byte array into Base64 notation. Does not GZip-compress data. * * <p> * As of v 2.3, if there is an error, the method will throw an java.io.IOException. <b>This is new to v2.3!</b> In * earlier versions, it just returned a null value, but in retrospect that's a pretty poor way to handle it. * </p> * * * @param source The data to convert * @param off Offset in array where conversion should begin * @param len Length of data to convert * @return The Base64-encoded data as a String * @throws NullPointerException if source array is null * @throws IllegalArgumentException if source array, offset, or length are invalid * @since 1.4 */ public static String encodeBytes(final byte[] source, final int off, final int len) { // Since we're not going to have the GZIP encoding turned on, // we're not going to have an java.io.IOException thrown, so // we should not force the user to have to catch it. String encoded = null; try { encoded = encodeBytes(source, off, len, NO_OPTIONS); } catch (final java.io.IOException ex) { assert false : ex.getMessage(); } // end catch assert encoded != null; return encoded; } // end encodeBytes
/** * Encodes a byte array into Base64 notation. Does not GZip-compress data. * * <p> * As of v 2.3, if there is an error, the method will throw an java.io.IOException. <b>This is new to v2.3!</b> In * earlier versions, it just returned a null value, but in retrospect that's a pretty poor way to handle it. * </p> * * * @param source The data to convert * @param off Offset in array where conversion should begin * @param len Length of data to convert * @return The Base64-encoded data as a String * @throws NullPointerException if source array is null * @throws IllegalArgumentException if source array, offset, or length are invalid * @since 1.4 */ public static String encodeBytes(final byte[] source, final int off, final int len) { // Since we're not going to have the GZIP encoding turned on, // we're not going to have an java.io.IOException thrown, so // we should not force the user to have to catch it. String encoded = null; try { encoded = encodeBytes(source, off, len, NO_OPTIONS); } catch (final java.io.IOException ex) { assert false : ex.getMessage(); } // end catch assert encoded != null; return encoded; } // end encodeBytes
/** * Generates a data URI from a byte array and outputs to the given writer. * * @param bytes * The array of bytes to output to the data URI. * @param out * Where to output the data URI. * @param mimeType * The MIME type to specify in the data URI. * @throws java.io.IOException */ private void generateDataURI(final byte[] bytes, final Writer out, final String mimeType) throws IOException { // create the output final StringBuffer buffer = new StringBuffer(); buffer.append(DATA_URI_PREFIX); // add MIME type buffer.append(mimeType); // output base64-encoding buffer.append(";base64,"); buffer.append(Base64.encodeBytes(bytes)); // output to writer out.write(buffer.toString()); } }
/** * Generates a data URI from a byte array and outputs to the given writer. * * @param bytes * The array of bytes to output to the data URI. * @param out * Where to output the data URI. * @param mimeType * The MIME type to specify in the data URI. * @throws java.io.IOException */ private void generateDataURI(final byte[] bytes, final Writer out, final String mimeType) throws IOException { // create the output final StringBuffer buffer = new StringBuffer(); buffer.append(DATA_URI_PREFIX); // add MIME type buffer.append(mimeType); // output base64-encoding buffer.append(";base64,"); buffer.append(Base64.encodeBytes(bytes)); // output to writer out.write(buffer.toString()); } }