This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Variables/properties used in property files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Variables/properties used in property files" Watch "Variables/properties used in property files" New topic
Author

Variables/properties used in property files

Stefan Anderssson
Greenhorn

Joined: Oct 27, 2008
Posts: 11
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"


Toto, I have a feeling we�re not in Kansas anymore
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19651
    
  18

Check out java.util.Properties. You could then use


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Stefan Anderssson
Greenhorn

Joined: Oct 27, 2008
Posts: 11
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

Joined: Oct 27, 2005
Posts: 19651
    
  18

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Variables/properties used in property files
 
Similar Threads
Static passwords
how to Initialize an ArrayList in a constructor with no parameters?
Rules Round Up #127
Properties are not variables
one question about JavaBean