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.
/home/user/.java/.userPrefs/com/mindprod/replicator/_!':!bw t!#4!b@p!'4!~!w!()!bwk!#4!cgl!(!!b!p!'}@"0!'8!cg==
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 |
http://mindprod.com/jgloss/preferences.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\preferences.html | |
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. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[18.221.119.21] |
| |
Feedback |
You are visitor number | |