Java Properties.getProperty() with an Array of Objects

1.4k Views Asked by At

I have a configuration file formatted as this,

object1=1
object2=2
object3=3
array={ 
   sub_object1=sub_1
   sub_object2=sub_2
   sub_object3=sub_3
}
object4=4
object5=5

I have been trying to process this with Properties.getProperty, but am unable to find an effective method to process the array.

    try {

        Properties props = new Properties();

        props.load( new FileInputStream( "settings.conf" ) );

        if( !props.isEmpty() ) 
        {
            props.stringPropertyNames().stream().forEach((key) -> 
            {
                if( !key.equals( "array" ) ) 
                {
                    List<Object> subkeys = props.list();

                    for( subkeys: subkey  ) )
                    {
                        System.out.println( "Subkey: " + props.getProperty( subkey ) );
                    }
                }
            });
        }
    } catch ( Exception e ) {
        e.printStackTrace();
    }

I realize the above is errorous, but I have been unable to find a solution. Any one have an idea?

0

There are 0 best solutions below