How do I tell netbeans to look in the resource folder for properties???

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How do I tell netbeans to look in the resource folder for properties???

dazz
Hello

I have a config.properties file.  
I have created a resources folder in the project to accommodate this file.  
I have gone to the project > properties > Sources  and added the resources folder. This now sits above the Source Package Folder entry.

So my understanding is that Netbeans will look for the config.properties file in the resources folder, but it doesn't.

Here is a snip of my code.  It fails on the first line after try.


Code:
public static void readProperties( ){
    logger.entering("iflag.flag.panel", "readProperties");
    //logger.entering(getClass().getName(), "doIt"); get* can't be used in a static method
    // create and load default properties
    Properties defaultProps = new Properties();
    InputStream input = null;
     try {
      File f = new File(configFilename);
      FileInputStream in = new FileInputStream( f );
      defaultProps.load(in);
      in.close();



Dazz




Reply | Threaded
Open this post in threaded view
|

How do I tell netbeans to look in the resource folder for properties???

dazz
Hi
So after some experimentation, I have worked out that if a file path starts with a back slash (eg.  /log.config.properties) then it is located in the root directory of the drive.

If a file path doesn't start with a back slash, (eg.  log.config.properties) it is located at the root of the class path.

The easiest way to find where a file is read from is to write a file and then search for it.