[jdom-interest] XMLOutputter clipping text ... a bug?

William Krick wkrick at eio-online.com
Fri Mar 5 12:33:37 PST 2004


Using JDOM b9, when I run an xml file...

-----begin test.xml-----
<?xml version="1.0" encoding="UTF-8"?><TEST>This is a test.</TEST>
------end test.xml------

...through the following code...


    String fileName = "test.xml";
    File f = new File(fileName);
    Document doc = null;

    //load the doc from the xml file
    SAXBuilder builder = new SAXBuilder();
    FileInputStream fis = null;
    try {
      fis = new FileInputStream(f);
      doc = builder.build(fis);
    }
    catch (Exception ex) {
    }
    finally {
      try { fis.close(); } catch (Exception ex) {}
    }

    //
    // you would do stuff to the doc here
    //


    // write the doc back out to the file
    XMLOutputter fmt = new XMLOutputter();
    FileOutputStream fos = null;
    try {
      fos = new FileOutputStream(f);
      fmt.output(doc, fos);
    }
    catch (Exception ex) {
    }
    finally {
      try { fos.close(); } catch (Exception ex) {}
    }


... it comes out with the beginning of the text clipped like this...

-----begin test.xml-----
ml version="1.0" encoding="UTF-8"?><TEST>This is a test.</TEST>
------end test.xml------



Is this a bug or am I doing something wrong?  This is REALLY frustrating.

...
Krick




More information about the jdom-interest mailing list