[jdom-interest] help XMLOutputter

Jay Burgess jburgess at delanotech.com
Fri Oct 26 07:51:21 PDT 2001


If I understand the problem correctly, then it may be due to the colons in 
the timestamp portion of your filename.  At least on Windows, a colon is 
not a valid filename character.  Here's a one-line way to generate a 
timestamp without colons:

     new SimpleDateFormat("HH.mm.ss.SSS").format(new Date())

You can add the datestamp as well if you look up the rest of the values for 
SimpleDateFormat.

Jay

-----Original Message-----
From: Lopez, William [mailto:william.lopez at eds.com]
Sent: Friday, October 26, 2001 8:54 AM
To: jdom-interest at jdom.org
Subject: [jdom-interest] help XMLOutputter


The issue I'm having is probably more of a "basic" coding issue than a JDOM
issue but I'll try my luck here first.

I'm attempting to use the XMLOutputter class to create XML files from a JDOM
object that is retrieving Clob files from a database so I can see the test
data. Here's the code for that piece:

       inputsource = new InputSource(is);
       doc = builder.build(inputsource);

       StringBuffer sb = new StringBuffer();
       String wholeTime = new
java.sql.Timestamp(System.currentTimeMillis()).toString();
       String date = wholeTime.substring(0, 10);
       sb.append(date).append("_");
       sb.append(wholeTime.substring(11,19));
       String newTime = sb.toString();

       String file = "c:/Documents and
Settings/xzs3h2/jbproject/DTDMap/acceptance.xml";
       OutputStream os = new FileOutputStream(file, true);
       XMLOutputter xo = new XMLOutputter("   ", true, "UTF-8");
       xo.setTextNormalize(true);
       xo.output(doc, os);

This works but I don't want to append [new FileOutputStream(file, true);]
each XML image in the one acceptance.xml file. I was trying to use the
following code to create different file names: String file = "c:/Documents
and Settings/xzs3h2/jbproject/DTDMap/" + newTime + "_acceptance.xml"; but I
was receiving a "bad parameter" error message at: OutputStream os = new
FileOutputStream(file, true);

Sorry for the newbie question but any suggestions would be appreciated.

Thanks,

William Lopez
EDS - Health and Insurance Solution Centre
MS C3-1C-37
5400 Legacy Drive
Plano, TX 75024

* phone: +01-972-604-3372 (834-3372)
* mailto:william.lopez at eds.com
www.eds.com






More information about the jdom-interest mailing list