src/main/java/com/simpligility/maven/plugins/android/standalonemojos/ManifestUpdateMojo.java
private void writeManifest( File manifestFile, Document doc ) throws IOException, TransformerException
    {
        TransformerFactory xfactory = TransformerFactory.newInstance();
        Transformer xformer = xfactory.newTransformer();
        xformer.setOutputProperty( OutputKeys.OMIT_XML_DECLARATION, "yes" );
        Source source = new DOMSource( doc );

        OutputStreamWriter writer = null;
        try
        {
            manifestFile.getParentFile().mkdirs();

            String encoding = doc.getXmlEncoding() != null ? doc.getXmlEncoding() : "UTF-8";
            writer = new OutputStreamWriter( new FileOutputStream( manifestFile, false ), encoding );
            if ( doc.getXmlEncoding() != null && doc.getXmlVersion() != null )
            {
                String xmldecl = String
                    .format( "<?xml version=\"%s\" encoding=\"%s\"?>%n", doc.getXmlVersion(), doc.getXmlEncoding() );
                writer.write( xmldecl );                
            }
            Result result = new StreamResult( writer );

            xformer.transform( source, result );
        }
        finally
        {
            IOUtils.closeQuietly( writer );
        }
    }
private void writeManifest( File manifestFile, Document doc ) throws IOException, TransformerException
    {
        TransformerFactory xfactory = TransformerFactory.newInstance();
        Transformer xformer = xfactory.newTransformer();
        xformer.setOutputProperty( OutputKeys.OMIT_XML_DECLARATION, "yes" );
        Source source = new DOMSource( doc );

        OutputStreamWriter writer = null;
        try
        {
            manifestFile.getParentFile().mkdirs();

            String encoding = doc.getXmlEncoding() != null ? doc.getXmlEncoding() : "UTF-8";
            writer = new OutputStreamWriter( new FileOutputStream( manifestFile, false ), encoding );
            if ( doc.getXmlEncoding() != null && doc.getXmlVersion() != null )
            {
                String xmldecl = String
                    .format( "<?xml version=\"%s\" encoding=\"%s\"?>%n", doc.getXmlVersion(), doc.getXmlEncoding() );
                writer.write( xmldecl );                
            }
            Result result = new StreamResult( writer );

            xformer.transform( source, result );
        }
        finally
        {
            IOUtils.closeQuietly( writer );
        }
    }
private void writeManifest ( File manifestFile , Document doc ) throws IOException , TransformerException { TransformerFactory xfactory = TransformerFactory . newInstance ( ) ; Transformer xformer = xfactory . newTransformer ( ) ; xformer . setOutputProperty ( OutputKeys . OMIT_XML_DECLARATION , "yes" ) ; Source source = new DOMSource ( doc ) ; OutputStreamWriter writer = null ; try { manifestFile . getParentFile ( ) . mkdirs ( ) ; String encoding = doc . getXmlEncoding ( ) != null ? doc . getXmlEncoding ( ) : "UTF-8" ; writer = new OutputStreamWriter ( new FileOutputStream ( manifestFile , false ) , encoding ) ; if ( doc . getXmlEncoding ( ) != null && doc . getXmlVersion ( ) != null ) { String xmldecl = String . format ( "<?xml version=\"%s\" encoding=\"%s\"?>%n" , doc . getXmlVersion ( ) , doc . getXmlEncoding ( ) ) ; writer . write ( xmldecl ) ; } Result result = new StreamResult ( writer ) ; xformer . transform ( source , result ) ; } finally { IOUtils . closeQuietly ( writer ) ; } }
Write manifest using JAXP transformer
Write manifest using JAXP transformer