public byte [ ] serializeDoc ( ) throws IOException { XmlDomWriter xw = new XmlDomWriter ( ) ; ByteArrayOutputStream fout = new ByteArrayOutputStream ( ) ; xw . setOutput ( fout , null ) ; fout . write ( XmpWriter . XPACKET_PI_BEGIN . getBytes ( "UTF-8" ) ) ; fout . flush ( ) ; NodeList xmpmeta = domDocument . getElementsByTagName ( "x:xmpmeta" ) ; xw . write ( xmpmeta . item ( 0 ) ) ; fout . flush ( ) ; for ( int i = 0 ; i < 20 ; i ++ ) { fout . write ( XmpWriter . EXTRASPACE . getBytes ( ) ) ; } fout . write ( XmpWriter . XPACKET_PI_END_W . getBytes ( ) ) ; fout . close ( ) ; return fout . toByteArray ( ) ; }
Writes the document to a byte array .