Hi, I am trying to construct a File object. I want to specify a relative path for the file name. If I specify the absolute path, it works file like File F = new File("C:\\myFile","myFile.xml");
But if I want to access the file in the same folder and say File F = new File("myFile.xml");
It says file not found.
How do I specify the file path without specifying the full path so that the code will be system independent.
Pls advise.
Regards, Jay.
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
9
posted
0
Try printing the value of to make sure your working directory is actually the location of the myFile.xml file.
Joanne
Jay Ram
Ranch Hand
Joined: Dec 13, 2005
Posts: 40
posted
0
Thx for the response Joanne.
I tried that and as u had suggested, the current working directory is different. I am working with weblogic workshop and apparently the classes are stored in a different directory. How do I specify the directory now? Where do I put the file? I am tryimg to parse an XML file frfom inside my class.
Please advise.
Regards, jaya.
Joanne Neal
Rancher
Joined: Aug 05, 2005
Posts: 3011
9
posted
0
If you want to be completely system independent you will need to tell your program where the file is, either using a command line argument to your program, a -D option to java or storing it in a configuration file or database that gets created by your install program. [ June 22, 2006: Message edited by: Joanne Neal ]
Jay Ram
Ranch Hand
Joined: Dec 13, 2005
Posts: 40
posted
0
Thanks Joanne. Will try it by storing it in a properties file.