Thomas O'Neill wrote:
I am using castor's XML Mapping to Marshall an Object in my Struts
application.  When I load the XML file with FileReader I have to
specifiy and abosulote path in order to avoid throwing a
FileNotFoundException.  Could anyone tell me how to use a relative
path with FileReader?

Thanks!

This is the exception when i try to use a relative path:
java.io.FileNotFoundException: user.xml (The system cannot find the
file specified)

This code works with an absolute path:
User testuser = (User) Unmarshaller.unmarshal(User.class,
                                        new 
FileReader("C:\\ApacheGroup\\Tomcat4\\webapps\\test_app\\user.xml"));



Does this help:

InputSource is = new InputSource(this.getClass().getClassLoader().getResourceAsStream("user.xml"));
User testuser = (User) Unmarshaller.unmarshal(User.class, is);


Stein



----------------------------------------------------------- If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-user

Reply via email to