This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ClassLoader

 
ravikant
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
regards
ravikant
 
James Mead
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
James
 
Junilu Lacar
Bartender
Pie
Posts: 7319
45
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"rvm76"
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic