• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

properties file location

 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there a way to find a properties file from a class no matter where it is on the disk? I know you can use a getProperty() method to find the jdk ext directory and I could put my properties file there. I have a properties file which holds locations of other files. It would seem I'd need a properties file to hold the location of the properties file, and another properties file to hold the location of that properties file and so on . . .
I'd like to just name the file in the class, and not worry about which directory it's located in.
Thanks.
Paul
 
Bartender
Posts: 1843
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depends on how flexible you want to be. You could use the java.io.File class to walk the directory structure of the disk looking for the file, but I don't recommend that
Instead, I just put my properties in classpath and don't worry about the directory. Loading the Properties through PropertyResourceBundle.getBundle("myPropertiesFile") uses the classpath, so as long as my file is in the classpath I don't worry about it. If I don't have a resource in the classpath, I don't have the resource.
(Of course, I'm looking at moving to Preferences anyway...)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic