A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Java in General
Loading an XML file in a classpath
Joined: Jan 03, 2004
Feb 11, 2007 10:00:00
I have a requirement where I have a an XML config file. the path of this config file is specified in the classpath. I need to load this config file at run time by just specifying the name of the file.
Eg. Assume the file abc.xml is in c:/temp/abc.xml. and my classpath is set c:/temp;
and I want to do something like this.
File file = new File("abc.xml");
Does the JRE furnish the complete the path of the file at run time?
Is something like this possible?
Joined: Dec 13, 2006
Feb 11, 2007 10:09:00
You can use this to get the URL of the file:
URL url = Thread.currentThread().getContextClassLoader().getResource("/abc.xml");
I agree. Here's the link:
subject: Loading an XML file in a classpath
please help me
How to Create a Byte Arrary from a XML File?
modifying Jboss classpath
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2013