Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Loading a property file from a fixed folder in the filesystem

 
Gabriele Giambartolomei
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello folks,

I have a file called outbound.properties that I load in my Java application. This file at the moment is in the /src directory of my project and I load it using something like:
InputStream input = MailService.class.getResourceAsStream(Constants.Session.OUTBOUND_PROPERTIES_FILE); where OUTBOUND_PROPERTIES_FILE is define as "/outbound.properties/ and is the name of the file and it all work prefectly !
Now, I would like to put the property file outside my project folder, for example in the folder C:\data of my filesystem. I tried to change the name of the OUTBOUND_PROPERTIES_FILE in "C:\data" but I get a
WARNING: Configuration file:/data/outbound.properties not found, using defaults. Of course the file it is there !

How can I load a java property file from an absolute path in my filesystem, for example C:\data\myConfigFiles ?

Thanks a lot in advance for your help !
Gabriele
 
Paul Clapham
Sheriff
Posts: 21107
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like this:

The Class.getResourceAsStream() method gets an input stream from a resource which is defined relative to your classpath. That isn't what you want.
 
Gabriele Giambartolomei
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Paul,

many thanks for your quick reply ! It was driving me crazy ! I will try to do it the way you seggested me and see how it goes.
Thanks a lot !
Gabriele
 
James Boswell
Bartender
Posts: 1051
5
Chrome Eclipse IDE Hibernate
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gabriele

Try loading it using a URI:

http://docs.oracle.com/javase/6/docs/api/java/net/URI.html
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic