Java XML Transform Usage encodeBase64(Element elm)

Here you can find the source of encodeBase64(Element elm)

Description

encode Base

License

Open Source License

Declaration

public static String encodeBase64(Element elm) throws Exception 

Method Source Code


//package com.java2s;
import java.io.ByteArrayOutputStream;

import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import org.apache.commons.codec.binary.Base64;

import org.w3c.dom.Element;

public class Main {
    public static String encodeBase64(Element elm) throws Exception {
        ByteArrayOutputStream ostream = new ByteArrayOutputStream();
        TransformerFactory transFac = TransformerFactory.newInstance();
        Transformer trans = transFac.newTransformer();
        trans.transform(new DOMSource(elm), new StreamResult(ostream));
        return (new String(Base64.encodeBase64(ostream.toByteArray(), true)));
    }/* www .  j a v a 2  s.  c  o m*/
}

Related

  1. createUnixStreamResultForEntry(OutputStream outputEntry)
  2. dateToGregorian(Date date)
  3. DateToXML(Date date)
  4. dumpMetadata(IIOMetadata meta)
  5. dumpMetadataToSystemOut(IIOMetadata iiometa)
  6. getCalendarAsXsdDateTime(Calendar c)
  7. getContentText(Element element)
  8. getDate(final XMLGregorianCalendar xmlGregorianCalendar)
  9. getEmptyXmlFile(File xmlFile)