You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Konstantinos Pachopoulos <ko...@yahoo.gr> on 2007/12/22 14:11:09 UTC
configuration-Properties: cannot define a property based upon another one
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
___________________________________________________________
Yahoo! Answers - Got a question? Someone out there knows the answer. Try it
now.
http://uk.answers.yahoo.com/
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org
Re: configuration-Properties: cannot define a property based upon
another one
Posted by Oliver Heger <ol...@oliver-heger.de>.
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