• 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
  • Paul Clapham
  • Bear Bibeault
  • Liutauras Vilda
  • Devaka Cooray
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Loading Properties file into a list

 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys

We have data for 35 entries in a properties file.

Each entry represents a Value Object.

We want to read this data into a set of objects.

how do we do that?

Thanks




 
Bartender
Posts: 4121
IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not completely sure what you're trying to do...

But the util:properties tag might help.
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In Spring, you can use something like this:

 
ranger
Posts: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

robson vargas wrote:In Spring, you can use something like this:



Or use util:properies and inject the Properies bean into your class that needs the values. Or inject in that class, then have the setter method go through the properties and populate a List, if you need a List of them. But what are you going to put in the List just the keys or just the values, or is your Value Object has two properties, one for the key and one for the value?

Mark
 
Mark Spritzler
ranger
Posts: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

James Winfrey wrote:Hi Guys

We have data for 35 entries in a properties file.

Each entry represents a Value Object.

We want to read this data into a set of objects.

how do we do that?

Thanks



Or if you are using Spring 3.0+ you can use SPeL.



If you don't want the set method to have code to create the list. And now you could inject the List into your object. It is a bit more configuration than just the Property injected into your classes and calling getProperty() methods in code

Mark
 
Mark Spritzler
ranger
Posts: 17344
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or if you don't need the List


Mark
 
Switching from electric heat to a rocket mass heater reduces your carbon footprint as much as parking 7 cars. Tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!