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 / November 2006

Tip: Looking for answers? Try searching our database.

Can java.util.Properties store binary data

Thread view: 
Rebus77 - 16 Nov 2006 21:29 GMT
Guys,

I am trying to write a class similar to java.lang.Properties, except
that the entries should be in order (alphabetically), and it should
also be able to store binary data(ie public key and digital signature).

... but I do not want to reinvert the wheel. Is there such a class in
the JDK? or something similar?

I am trying to use SortedMap, and write out the entries one by one in a
file, using Base64 to encode the binary data... but that puts '='s in
... I am having some trouble reading the binary data back.
Timothy Bendfelt - 16 Nov 2006 21:43 GMT
If you write the file using the store() method on properties the necessary
escaping will be applied to characters within the value such that it can
be parsed by the load() method.  That way you can use whatever string
encoding you want (i.e. base64) for your binary serialization.

> Guys,
>
[quoted text clipped - 8 lines]
> file, using Base64 to encode the binary data... but that puts '='s in
> ... I am having some trouble reading the binary data back.
Thomas Weidenfeller - 17 Nov 2006 08:09 GMT
> I am trying to write a class similar to java.lang.Properties, except
> that the entries should be in order (alphabetically), and it should
> also be able to store binary data(ie public key and digital signature).

Java comes with a key store for digital signatures. Maybe that would
work better for you.

/Thomas
Signature

The comp.lang.java.gui FAQ:
http://gd.tuwien.ac.at/faqs/faqs-hierarchy/comp/comp.lang.java.gui/
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq

Dale King - 28 Nov 2006 12:58 GMT
> Guys,
>
> I am trying to write a class similar to java.lang.Properties, except
> that the entries should be in order (alphabetically),

java.util.Properties is an example of why one should follow the design
principle of favoring composition over inheritance. Properties is a
subclass of Hashtable. That means it will always be backed by a
Hashtable. Instead they should have used composition and Properties
should have contained an instace of a Map and you would be able to
choose the Map implementation.

> and it should
> also be able to store binary data(ie public key and digital signature).

> file, using Base64 to encode the binary data... but that puts '='s in
> .... I am having some trouble reading the binary data back.

Properties only does text data. You have to convert it to text as you
suggested.

The = should be insignificant after the initial separator between the
key and value. Are you sure that the problem is not that the base64 is
broken over more than one line and you are not escaping the newline?

Signature

 Dale King



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.