Another technique would be to serialize with a ByteArrayOutputStream ⇒ ObjectOutputStream and use putByteArray. The problem with that method is the registry would be unintelligible (it is encoded in Base64) and you could not do manual patching. The other catch is keys are limited to 80 bytes and values to a mere 8K.
systemNodeForPackage lets you specify Preferences for the whole machine for each package. userNodeForPackage lets you specify Preferences for a particular user for that package. If the package is used in more than one context, e.g. the same class used in two different programs or the same class is used to manage two separate sets of files, it is up to you to create another level of name to keep track of the context. Note though you specify a class name, the Preferences are on a per package, not a per class basis.
The registry will be more legible with regedit if you stick to lower case keys and values since upper case values are encoded in a bizarre fluffy way.
The contents of the file will look something like this:
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE map SYSTEM "http://java.sun.com/dtd/preferences.dtd"> <map MAP_XML_VERSION="1.0"> <entry key="LAN_ZIP_URL" value="http://mindprod.com/replicator"/> <entry key="PASSWORD" value=""/> <entry key="PREFS_EXIST" value="true"/> <entry key="RECEIVER_BASE_DIR" value="/home/Mindprod"/> <entry key="RECEIVER_ZIP_STAGING_DIR" value="/home/MPstaging"/> <entry key="USERID" value=""/> </map>
Alternatives include writing data to a server, storing it in an SQL database, storing in a POD (Persistent Object Database) and storing in ini, CSV (Comma-Separated Value), DataOutputStream or serialised disk files.
This page is posted
Optional Replicator mirror
Please read the feedback from other visitors, or send your own feedback about the site.
Contact Roedy. Please feel free to link to this page without explicit permission.
Your face IP:[184.108.40.206]
You are visitor number|