Hello!

I'am reading some packageParts of a docx Files.
This files are transferred to a org.w3c.dom.Document when I write out this stream to the part in the OutputStream some characters where corrupted.

This are characters like
ö,ä,ü and so on.

Is there something to check on.
Enclosed my code.

Thanks a lot!

Greetings

Christian

Reading from InputStream

        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        DocumentBuilder builder;

        try {
                factory.setIgnoringElementContentWhitespace(true);
                builder = factory.newDocumentBuilder();
                domDocument = builder.parse(coreDoc.getInputStream(),"UTF-8");

        }catch....


Writing to OutputStream

        TransformerFactory tf = TransformerFactory.newInstance();

        Transformer transformer = tf.newTransformer();
        transformer.setOutputProperty(OutputKeys.STANDALONE, "yes");

        domDocument.setXmlStandalone(true);
        DOMSource source = new DOMSource(domDocument);
        StringWriter writer = new StringWriter()
        StreamResult result = new StreamResult(writer);

        transformer.transform(source, result);
        String strDocument = writer.toString();
        mpOut = coreDoc.getOutputStream();
        mpOut.write(strDocument.getBytes(),0,strDocument.length());
        mpOut.close();


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to