Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / December 2007

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Sonal - 06 Dec 2007 05:32 GMT
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.
Manish Pandit - 06 Dec 2007 05:59 GMT
> Hi All,
>
[quoted text clipped - 8 lines]
>
> 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
Daniele Futtorovic - 06 Dec 2007 22:45 GMT
> Hi All,
>
[quoted text clipped - 6 lines]
> 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.
Lew - 07 Dec 2007 03:08 GMT
>> Hi All,
>>
[quoted text clipped - 10 lines]
> don't see entrySet() or the like overridden in Properties, so it will be
> Hashtable's version, which won't include the defaults.

Maybe there's some help to be had from
<http://java.sun.com/javase/6/docs/api/java/util/Properties.html#Properties(java.
util.Properties
)>

Signature

Lew



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.