jQuery in Action, 3rd edition
The moose likes I/O and Streams and the fly likes ClassLoader Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "ClassLoader" Watch "ClassLoader" New topic



Joined: Apr 25, 2002
Posts: 5
I want to make jdbc connection in java object,
wants to read some properties file which will be
containing detail about db server like sid,port and ip.
I used ClassLoader.getResourceAsStream method, if
i copy that property file in jdk/lib folder, then it works. If i keep it some where else it won't work?
please tell me how this ClassLoader works?
James Mead

Joined: Apr 19, 2002
Posts: 6
This isn't really relevant to this forum - "JDBC" or "I/O and Streams" would have been better.
The ClassLoader method you mention will find any file on the classpath, but I think you are barking up the wrong tree! This class is designed for loading the byte code for java class files.
You should use the ResourceBundle class in the java.util package for loading a properties file.
Junilu Lacar

Joined: Feb 26, 2001
Posts: 6529

Please review the JavaRanch Naming Policy then edit your profile so that your publicly displayed name complies with the rules. Thanks for your cooperation.
Moving this to I/O
I agree. Here's the link: http://aspose.com/file-tools
subject: ClassLoader
It's not a secret anymore!