Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

properties file location  RSS feed

 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • 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: 1840
Eclipse IDE Java Ruby
  • Mark post as helpful
  • send pies
  • 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...)
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!