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 / February 2006

Tip: Looking for answers? Try searching our database.

Specifying a file's directory

Thread view: 
stephanj - 23 Feb 2006 10:17 GMT
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);

           .
           .
           .
           .

Rather than specify the FULL path eg C:\\.....  can I just use a relative
path of the
properties file for the above file?

Maybe something like ( I know it is not correct)

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

Any help appreciated.
tom fredriksen - 23 Feb 2006 10:26 GMT
> 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


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.