File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting data from files in your CLASSPATH

 
Felix Ulrich
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi gang
I'd like to retrieve information from files in the classpath of the running VM - e.g. .properties files. Is there a way of doing this without having to supply the physical location of the file on disk?
Thanks
Felix.
 
Mohamed Yousuff
Ranch Hand
Posts: 73
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

You can get the information of your environment using System.getProperties(). The return type is java.util.Properties. I hope you can get information on the classpath also using this. Good Luck
Originally posted by Felix Ulrich:
Hi gang
I'd like to retrieve information from files in the classpath of the running VM - e.g. .properties files. Is there a way of doing this without having to supply the physical location of the file on disk?
Thanks
Felix.

 
Felix Ulrich
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm afraid that's not much help - it only get System properties - e.g. user.dir, os.version, etc. I want to include a something.conf file in my classpath, and then load it from within my application, without using the File stuff in java.io.
Felix.
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THere's a get resourec or some such in either Class or ClassLoader (CL is my guess). I used it just the other day.
(Sorry this is deliberately vague but I'm tired and it's kinder than rtfm... )
Dave
 
Felix Ulrich
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dave - that's kind of what I've been trying:
InputStream is = ClassLoader.getSystemClassLoader().getSystemResourceAsStream("/db.conf");
I've also tried just getResourceAsStream(), but the input stream returned is null, and I know for sure that the file has stuff in it and that it is in the root of the classpath.
Felix =(
 
Geoffrey Falk
Ranch Hand
Posts: 171
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am having the same problem. Can anyone answer? :roll:
Thanks
Geoffrey
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic