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

William Krick wkrick at eio-online.com
Fri Mar 5 13:50:26 PST 2004


It comes out fine in system out but not in the file.

If I send the output to a different file instead of the same file, it works
correctly.

I would think that as long as I close the FileInputStream before I open the
FileOutputStream, it should be okay using the same file.

I'm at a loss as to what the heck is happening here.




-----Original Message-----
From: jdom-interest-admin at jdom.org
[mailto:jdom-interest-admin at jdom.org]On Behalf Of Jason Hunter
Sent: Friday, March 05, 2004 4:42 PM
To: William Krick
Cc: jdom-interest at jdom.org
Subject: Re: [jdom-interest] XMLOutputter clipping text ... a bug?


I've never heard of this before.  I'm going to guess it has to do with
your stream.  Dump it to System.out for another view.

-jh-

William Krick wrote:

> 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
>
> _______________________________________________
> To control your jdom-interest membership:
>
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com
>
_______________________________________________
To control your jdom-interest membership:
http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhos
t.com




More information about the jdom-interest mailing list