Ole Wendland wrote:
> Hello Guys,
> please tell me whats the problem with this delimiter.
> The Program is this one:
>
> import org.apache.commons.configuration.*;
> import java.io.*;
> import java.util.List;
>
> class SaveProperties
> { public static void main( String[] args )
> {
>
> try { PropertiesConfiguration config = new
> PropertiesConfiguration("test.txt");
> config.setListDelimiter('|');
>
> System.out.println(System.out.println(config.getList("test").get(0));
>
> } catch (ConfigurationException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
> }
> }
>
> and the test.txt looks like this
> test = one|two|three
>
> The output I expect should be "one" but he can't split the List and
> gives me "one|two|three". When I use a comma as Delimiter is everything
> fine.
> What is my mistake?
>
> Greetings Ole
You have to set the delimiter before you load the configuration. Follow
this pattern:
PropertiesConfiguration config = new PropertiesConfiguration();
config.setListDelimiter('|');
config.load("test.txt");
(There is a note about this behavior in the Javadocs for the
setListDelimiter() method in AbstractConfiguration.)
Oliver
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]