Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Variables/properties used in property files

 
Stefan Anderssson
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it possible to use variables (or, I guess, properties) in a property file? What I'd like to do is something like...
something=abc
somethingElse={something}123

...where the value of "somethingElse" would be: "abc123"
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Check out java.util.Properties. You could then use
 
Stefan Anderssson
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply. The example I used was somewhat silly (perhaps something with files and paths would be better) though. I've used java.util.Properties, but I wouldn't mind being able to do something like the example above in the property files. If it isn't possible, I guess I can live with that. Or, at least, adapt.
 
Rob Spoor
Sheriff
Pie
Posts: 20527
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Or subclass Properties
Override getProperty:

Notice the recursive call. It could lead to problems if you have a loop though, so be careful about that.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic