• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Read key and value from properties file

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
How can I read multiple key and value from properties file.
can any one help me please

Thanks in advance
Abhay
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you want it as a bean to inject into your classes. you can use the util namespace and

<util:properties id="myProps" location="location of .properties file"/>

Or do you just mean myPropertiesInstance.getProperty("propertyNameHere");

Mark
 
Abhay Choubey
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replay. It is not solving my problem-

My properties file is like -

P1 = com.tt.example1
p2 = com.tt.example2
p3 = com.tt.example3.

here com.tt.example1,example2,example3 is java class. How can I read all value at a time using spring configuration file. It should not be hard code.\

Thanks in advance
Abhay
 
Mark Spritzler
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Abhay Choubey wrote:Thanks for your replay. It is not solving my problem-

My properties file is like -

P1 = com.tt.example1
p2 = com.tt.example2
p3 = com.tt.example3.

here com.tt.example1,example2,example3 is java class. How can I read all value at a time using spring configuration file. It should not be hard code.\

Thanks in advance
Abhay



My question is still the same? How exactly do you want to use the values, It makes a big difference in the answer.

Look at the PropertyPlaceholderConfigurer in the Spring Framework documentation to see if that is what you need. Are you using Spring 3.x, if so, then I recommend reading about the Spring Expresssion language in the Spring Framework documentation.

Thanks

Mark

 
"How many licks ..." - I think all of this dog's research starts with these words. Tasty tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic