/** * Encodes a byte array into Base64 notation. Does not GZip-compress data. * * @param source * The data to convert * @since 1.4 */ public static String encodeBytes(byte[] source) { return encodeBytes(source, 0, source.length, NO_OPTIONS); } // end encodeBytes
/** * Encodes a byte array into Base64 notation. Does not GZip-compress data. * * @param source * The data to convert * @param off * Offset in array where conversion should begin * @param len * Length of data to convert * @since 1.4 */ public static String encodeBytes(byte[] source, int off, int len) { return encodeBytes(source, off, len, NO_OPTIONS); } // end encodeBytes
/** * Encodes a byte array into Base64 notation. * <p> * Valid options: * * <pre> * GZIP: gzip-compresses object before encoding it. * DONT_BREAK_LINES: don't break lines at 76 characters * <i>Note: Technically, this makes your encoding non-compliant.</i> * </pre> * * <p> * Example: <code>encodeBytes( myData, Base64.GZIP )</code> or * <p> * Example: * <code>encodeBytes( myData, Base64.GZIP | Base64.DONT_BREAK_LINES )</code> * * * @param source * The data to convert * @param options * Specified options * @see Base64#GZIP * @see Base64#DONT_BREAK_LINES * @since 2.0 */ public static String encodeBytes(byte[] source, int options) { return encodeBytes(source, 0, source.length, options); } // end encodeBytes
public Map execute(Map inputs) throws TaskExecutionException { Map results = new HashMap(); byte[] bytes = (byte[]) ((DataThing) inputs.get("bytes")).getDataObject(); String base64 = Base64.encodeBytes(bytes); results.put("base64", new DataThing(base64)); return results; }
realDataElement.setText(Base64.encodeBytes(theBytes)); dataElement.addContent(realDataElement); return dataElement;
private Element buildElementFromObject(String key, Object dataObject) throws JDOMException, IOException { Element dataElement = null; if (isXMLInput(key)) { dataElement = createDataElementForXMLInput(dataObject, key); } else { dataElement = new Element(key); setDataElementNamespace(key, dataElement); if (dataObject.toString().equals("nil")) { dataElement.setAttribute("nil", "true"); // changes nil value // to nil=true // attribute. } else { if (dataObject instanceof byte[]) { dataElement .setAttribute( "type", "xsd:base64Binary", org.jdom.Namespace .getNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance")); dataObject = Base64.encodeBytes((byte[]) dataObject); } dataElement.setText(dataObject.toString()); } } return dataElement; }