File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 19760
    
  20

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: 19760
    
  20

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