A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
How to make it relative path?
Joined: Mar 09, 2006
Aug 30, 2007 02:18:00
Suppose I create my
in = new
, is there any way else to access parameters.xml without using the hardcoded-path that way?
Roger F. Gay
Joined: Feb 16, 2007
Aug 30, 2007 04:12:00
If the path is relative to your application, then:
If you want a configurable path, place a configuration file where your application knows where to find it (relatively speaking) and read the path from the configuration file.
Correlation does not prove causality.
Joined: Dec 06, 2005
Aug 30, 2007 04:42:00
here is an example Code:
File f1 = new File("Test.java"); String path = f1.getAbsolutePath(); FileInputStream fis = new FileInputStream(path);
is this what you looking for..
How To Ask Questions On JavaRanch
Joined: Jan 29, 2003
Aug 30, 2007 13:04:00
Relative to what might be the question. This line:
File f1 = new File("..\Test.java");
will create a file relative to the current user directory. See
to get the current home.
You can also make a file relative to another file or a path
new File( homeDirectory, "..\Test.java" )
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
I agree. Here's the link:
subject: How to make it relative path?
retrieve a file from a fileinputstream
Is indexof only way of identify in file type
need help!!! please
NX:window XP - java.io.FileNotFoundException
reading a file without mentioning the whole path
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014