commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Oliver Heger <oliver.he...@oliver-heger.de>
Subject Re: configuration-Properties: cannot define a property based upon another one
Date Sat, 22 Dec 2007 15:38:33 GMT
Konstantinos Pachopoulos wrote:
> Hi,
> Given a properties file, which contains this:
> -------------------
> b = asd
> a = ${b}safk
> -------------------
> I -when reading property 'a'- get "${b}safk".
> 
> This is the program i use for reading the properties:
> ---------------------
> import java.io.*;
> import org.apache.commons.configuration.*;
> 
> public class PropsTest 
> {
>     public static void main(String[] args)
>     {
>         PropertiesConfiguration props_=new
> PropertiesConfiguration();
>         try {
>             props_.load(new FileReader("C:/Documents
> and Settings/paxosk/My Documents/a.props"));
>         }
>         catch(Exception e) {
>             System.err.println("failed to parser
> properties file... exiting/n"+
>                     e.getMessage());
>             System.exit(-1);
>         }        
>         
>        
> System.out.println((String)props_.getProperty("a"));  
>      
>     }//main
> }
> --------------------
> 
> What's the problem?
> 
> Thanks
> 
The getProperty() method does not do any variable substituation as is
pointed out in its javadocs [1]. Use the getString() method instead.

Oliver

[1]
http://commons.apache.org/configuration/apidocs/org/apache/commons/configuration/Configuration.html#getProperty(java.lang.String)

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message