Not able to copy all properties using properties.putAll() method.

S

Sonal

Hi All,

Properties props;
Properties props_;

props_.putAll(props);

I want to copy all properties from "props" object to "props_".But it
fails to copy all values.
Please can any one tell me the reason ?


Thanks.
 
M

Manish Pandit

Hi All,

Properties props;
Properties props_;

props_.putAll(props);

I want to copy all properties from "props" object to "props_".But it
fails to copy all values.
Please can any one tell me the reason ?

Thanks.

Are you sure props is not empty? I wrote a little snippet to check it
out:

Properties p = new Properties();
p.put("A","a");
p.put("B","b");
Properties copy = new Properties();
copy.putAll(p);
System.out.println(p);
System.out.println(copy);

And here is the output:

{A=a, B=b}
{A=a, B=b}

-cheers,
Manish
 
D

Daniele Futtorovic

Hi All,

Properties props;
Properties props_;

props_.putAll(props);

I want to copy all properties from "props" object to "props_".But it
fails to copy all values.
Please can any one tell me the reason ?

Possibly because of the defaults. putAll(Map) will iterate the source. I
don't see entrySet() or the like overridden in Properties, so it will be
Hashtable's version, which won't include the defaults.

DF.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top