Hi mailing list,


I am using JDom to parse XML files. If I am right, you can use SAX as a parser, right?


Im currenty using this code to read in the XML file


        FileInputStream fileStream = new FileInputStream(xmlFile);

        Charset s = detectFileEncoding(xmlFile);

        InputStreamReader streamReader = new InputStreamReader(fileStream, s);

        SAXBuilder builder = new SAXBuilder();

        doc = builder.build(streamReader);


The detectFileEncoding-Method is based on http://code.google.com/p/juniversalchardet/ and works fine so far.


I’m wondering in which charset SAXBuilder is now storing the characters its getting from the InputStreamReader? Currently, everything works fine and I am getting UTF-8 as charset no matter what I put in.


The other question would be, how I can output the XML data to file in a different encoding than UTF8?


Thanks for your help and regards from Germany,


Marco Naetlitz
Working Student

ConVista Consulting AG
Im Zollhafen 15/17
50678 Köln

Phone    +49 (221) 888 26 - 331
Fax        +49 (221) 888 26 - 8331


ConVista Consulting AG       Geschäftsstellen: Köln, München, Walldorf       Handelsregister: HRB 50609 Amtsgericht Köln
Vorstand: Wolfgang Albers, Heiko Hülsebusch, Oliver Kewes, Thomas Möller, Daniel Neubieser
Aufsichtsratsvorsitzender: Volker Meis