Paul,

If the file is in a JAR you can generate a URL to access it.

either something along the lines of

ServletContext context = getServletConfig().getServletContext();
URL url = context.getResource("/path/file.xml");

or alternatively using the class loader

URL url = getClass().getResource("/path/file.xml");

Best regards

Robert

-----Original Message-----
From: Paul Wallace [mailto:[EMAIL PROTECTED]
Sent: 07 September 2005 07:51
To: Tomcat Developers List
Subject: io.File relative path constructor


 
Hi,
        A should-be easy one - I do not wish to define an absolute path
to a File as it will packaged in a JAR, therefore its path will change.
How do I construct a File relative to my src root, something like File
file = new File("/path/myFile.xml");? I tried passing in a URL, URI but
am getting:

Exception in thread "main" java.lang.IllegalArgumentException: URI is
not hierarchical

when I jar and run it. Am using Win XP + Java 1.5.

Thanks

Paul.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED] 
  
--------------------------------------------------------
 
The information contained in this message is intended only for the recipient, 
and may be a confidential attorney-client communication or may otherwise be 
privileged and confidential and protected from disclosure. If the reader of 
this message is not the intended recipient, or an employee or agent responsible 
for delivering this message to the intended recipient, please be aware that any 
dissemination or copying of this communication is strictly prohibited. If you 
have received this communication in error, please immediately notify us by 
replying to the message and deleting it from your computer. 
--------------------------------------------------------
 

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to