Specifying a file's directory

S

stephanj

Hi all,

I am using Netbeans V5.0 and using a properties file for an application.

How can I specify where the file is stored WITHOUT using the full path of
the properties
file.

For example, below is a snippet of my code

Properties props = null;
try {
// create a Properties object called "props"
props = new Properties();
File file = new File("C:\\###-01-Semester-1-####\\" +

\\Topic5Database\\src\\config\\database.properties");
FileInputStream in = new FileInputStream(file);
// load the file into the Properties object
props.load(in);
 
T

tom fredriksen

stephanj said:
How can I specify where the file is stored WITHOUT using the full path of
the properties
file.
Maybe something like ( I know it is not correct)

File file = new File("..\\config\\database.properties");

Why not try it and see how it works?

In most cases paths are relative to some root, f.ex. the directory where
the app i started from or where the data root of the application server
controlling the app. So just write a file to the current directory and
search for the file, that should give you the root of your setup.

/tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,069
Latest member
SimplyleanKetoReviews

Latest Threads

Top