Can java.util.Properties store binary data

R

Rebus77

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.
 
T

Timothy Bendfelt

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.
 
T

Thomas Weidenfeller

Rebus77 said:
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
 
D

Dale King

Rebus77 said:
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?
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,009
Latest member
GidgetGamb

Latest Threads

Top