views:

2365

answers:

4

define a default directory for Input files

dir.default=/home/data/in/

dir.proj1=dir.default /p1
dir.proj2=dir.default /p2
dir.proj3=dir.default /p3

is this possible?

+1  A: 

The java.util.Properties class won't do this for you. It wouldn't be too difficult to subclass Properties, override the load() method and do the substitution yourself.

highlycaffeinated
+3  A: 

Standard properties files are just key-value pairs. In the text format, Properties just separates key from value and does some simple things such as allowing escaped characters. You might be able to define entities in the verbose XML syntax.

If you want your own substitution syntax, then you can manipulate a returned value as you would with any other string. Alternatively, you could write your own version of Properties or do the substitution when generating the file.

Tom Hawtin - tackline
A: 

A new open source project provides variable substitution along with a few other features - although substitution may arguably be the most useful. It is a subclass of java.util.Properties, and will can be used by any other class that may take configuration information as Properties.

The new project is on google code, its called eproperties, you can have a look here: http://code.google.com/p/eproperties/

Paul
+1  A: 

This is what you want, it is a bit old , but may work for your needs.

Enabling constant substitution in Property Values

You can substitute a constant anywhere in the property value, and even have more than one constant within a value, as in the following example:

CONST_1 = shoes and ships
CONST_2 = sealing wax
SomeValue = {CONST_1} and {CONST_2}

In this example, the "SomeValue" property evaluates to "shoes and ships and sealing wax."

OscarRyz