We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › How can I check if xml file exists
Page Index Toggle Pages: 1
How can I check if xml file exists? (Read 1483 times)
How can I check if xml file exists?
Mar 4th, 2010, 9:45am
 
How can I check if xml file exists?

I am fighting with processing to check if xml file exists.
what I need is something like this

Code:
if (file.xml exists) 
{
do something with it

} else {

text("There is no xml document", 22, 40);
}


please someone help!
Re: How can I check if xml file exists?
Reply #1 - Mar 4th, 2010, 10:12am
 
Code:
File f = new File(dataPath("file.xml"));
if (!f.exists()) {
 println("File does not exist");
}


dataPath() helps you finding the path of a file located in your sketch's data folder.
Re: How can I check if xml file exists?
Reply #2 - Mar 4th, 2010, 10:19am
 
Yes!
That's it! I was going crazy with this code.
Thanks!
Page Index Toggle Pages: 1