[jdom-interest] testing for existance of xml file
Bartley, Chris P
cbartl03 at sprintspectrum.com
Tue Jun 25 08:38:24 PDT 2002
Perhaps something like this:
File xmlFile = new File("/usr/local/tomcat/myfile2.xml")
if (xmlFile.exists())
{
try
{
...
Document aDocument = builder.build(xmlFile);
...
}
}
else
{
...
}
> -----Original Message-----
> From: Paul Phillips [mailto:paul at partitura.com]
> Sent: Tuesday, June 25, 2002 10:16 AM
> To: jdom-interest at jdom.org
> Subject: [jdom-interest] testing for existance of xml file
>
>
> I'm sure this is an easy question. However, I am feeling my
> way in jdom,
> so pointers are appreciated!
>
> In code like this...
>
> try {
> SAXBuilder builder = new SAXBuilder();
> Document aDocument = builder.build(new
> File("/usr/local/tomcat/myfile2.xml"));
> Element rootElement = aDocument.getRootElement();
> Element childElement =
> rootElement.getChild("childElement");
> result = childElement.getText();
> } catch(JDOMException e) {
>
> } catch(NullPointerException e) {
>
> }
>
> What is the best way to test for the existance of myfile2.xml. If it
> doesn't exist, I want to create it. should I test to see if
> aDocument is
> null?
>
> Thanks
> Paul Phillips
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/yo
> uraddr at yourhost.com
>
More information about the jdom-interest
mailing list