Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Convertion from Resource bundle to Class Loader  RSS feed

 
Shiva Selvadurai
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently my application loads its properties using resource bundle , need to do some improvement on this ,since class loader will take care of absolute path and load the file in class path can anyone hive me a sample code to do this or an idea on this , this is to be performed in servlet.
 
Satish Chilukuri
Ranch Hand
Posts: 266
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use the getResourceAsStream() method on the ClassLoader and pass the returned InputStream as an argument while constructing a PropertyResourceBundle object.



You can also use the getResource() method which will return an URL object.

Alternately , you can use the getResourceAsStream() method on the ServletContext object, but you need to specify the path of your file relative to the context root.
 
Mark Spritzler
ranger
Sheriff
Posts: 17309
11
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is this a Servlets question? Moving this to the Java In General (Beginner) Forum.

Thanks

Mark
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!