Read comma separated properties with configuration2 in java -
i have property:
move.patternfile.include = *1a.txt,*2a.txt
and i'm trying put in list, using apache commons configuration2.
the code have :
configurations configs = new configurations(); abstractconfiguration config = configs.properties(new file(filename)); config.setlistdelimiterhandler(new defaultlistdelimiterhandler(','));
i can read others properties, 1 want still 1 size list.
this command retrieve values :
list<string> linclude = configuration.getlist(string.class, "patternfile.include");
can please?
based on this appears delimiter has set before properties read file. code below works when run it, generates warning.
parameters params = new parameters(); filebasedconfigurationbuilder<propertiesconfiguration> builder = new filebasedconfigurationbuilder<propertiesconfiguration>( propertiesconfiguration.class).configure(params.filebased() .setlistdelimiterhandler(new defaultlistdelimiterhandler(',')) .setfile(new file("test.properties"))); propertiesconfiguration config = builder.getconfiguration(); list<string> linclude = config.getlist(string.class, "patternfile.include"); system.out.println(linclude.size()); for(string item: linclude){ system.out.println(item); }
test.properties
patternfile.include = *1a.txt,*2a.txt
output
2
*1a.txt
*2a.txt
here warning see when run it:
jun 26, 2016 2:12:17 org.apache.commons.beanutils.fluentpropertybeanintrospector introspect warning: error when creating propertydescriptor public final void org.apache.commons.configuration2.abstractconfiguration.setproperty(java.lang.string,java.lang.object)! ignoring property. java.beans.introspectionexception: bad write method arg count: public final void org.apache.commons.configuration2.abstractconfiguration.setproperty(java.lang.string,java.lang.object) @ java.beans.propertydescriptor.findpropertytype(unknown source) @ java.beans.propertydescriptor.setwritemethod(unknown source) @ java.beans.propertydescriptor.<init>(unknown source) @ org.apache.commons.beanutils.fluentpropertybeanintrospector.createfluentpropertydescritor(fluentpropertybeanintrospector.java:177) @ org.apache.commons.beanutils.fluentpropertybeanintrospector.introspect(fluentpropertybeanintrospector.java:140) @ org.apache.commons.beanutils.propertyutilsbean.fetchintrospectiondata(propertyutilsbean.java:2234) @ org.apache.commons.beanutils.propertyutilsbean.getintrospectiondata(propertyutilsbean.java:2215) @ org.apache.commons.beanutils.propertyutilsbean.getpropertydescriptor(propertyutilsbean.java:950) @ org.apache.commons.beanutils.propertyutilsbean.iswriteable(propertyutilsbean.java:1466) @ org.apache.commons.configuration2.beanutils.beanhelper.ispropertywriteable(beanhelper.java:521) @ org.apache.commons.configuration2.beanutils.beanhelper.initproperty(beanhelper.java:357) @ org.apache.commons.configuration2.beanutils.beanhelper.initbeanproperties(beanhelper.java:273) @ org.apache.commons.configuration2.beanutils.beanhelper.initbean(beanhelper.java:192) @ org.apache.commons.configuration2.beanutils.beanhelper$beancreationcontextimpl.initbean(beanhelper.java:669) @ org.apache.commons.configuration2.beanutils.defaultbeanfactory.initbeaninstance(defaultbeanfactory.java:162) @ org.apache.commons.configuration2.beanutils.defaultbeanfactory.createbean(defaultbeanfactory.java:116) @ org.apache.commons.configuration2.beanutils.beanhelper.createbean(beanhelper.java:459) @ org.apache.commons.configuration2.beanutils.beanhelper.createbean(beanhelper.java:479) @ org.apache.commons.configuration2.beanutils.beanhelper.createbean(beanhelper.java:492) @ org.apache.commons.configuration2.builder.basicconfigurationbuilder.createresultinstance(basicconfigurationbuilder.java:447) @ org.apache.commons.configuration2.builder.basicconfigurationbuilder.createresult(basicconfigurationbuilder.java:417) @ org.apache.commons.configuration2.builder.basicconfigurationbuilder.getconfiguration(basicconfigurationbuilder.java:285) @ main.main.main(main.java:25)
i found this link regarding warning message.
Comments
Post a Comment