Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2005

Tip: Looking for answers? Try searching our database.

XML problems reading file in another directory

Thread view: 
simon_s_li@hotmail.com - 25 Oct 2005 11:05 GMT
Hi,

I am new to XML and I am trying to read an XML file 3 directory levels
up.

In the jsp I am setting the src to "..\..\..\directory\file.xml" and
I've tried "../../../directory/file.xml".  Both these methods don't
seem to be able pick the xml file up.

If I put the file in the same directory it works ok.

By the way, I cannot move the file to the same directory as lots of
other files read this file in the current directory.

Can you help??  What am I doing wrong??

Regards
Simon
Roedy Green - 25 Oct 2005 14:40 GMT
>In the jsp I am setting the src to "..\..\..\directory\file.xml" and
>I've tried "../../../directory/file.xml".  Both these methods don't
>seem to be able pick the xml file up.

You might try dumping the CWD.  You might be surprised.
Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.

Oliver Wong - 25 Oct 2005 22:36 GMT
> Hi,
>
[quoted text clipped - 11 lines]
>
> Can you help??  What am I doing wrong??

   If I take your explanation literally, it seems like the correct path
should be "..\..\..\file.xml", as you say it's 3 directories up, not 2
directories up, and 1 directory "sideways".

   Have you tried moving the file just one directory up and doing
"..\file.xml" to see if you're suffering from some sort of "off by 1" error?

   Have you tried creating a file object pointing to the current directory
and programmatically going up via .getParentFile()?

   - Oliver
Roedy Green - 26 Oct 2005 02:09 GMT
> "..\..\..\directory\file.xml"

Don't forget that in Java strings, \ has to be doubled.
and in regexes quadrupled to get a literal \.

Signature

Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.