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.
available on the web at:
optional Replicator mirror
Please email your feedback for publication, letters to the editor, errors, omissions, typos, formatting errors, ambiguities, unclear wording, broken/redirected link reports, suggestions to improve this page or comments to Roedy Green : . If you want your message, your name or email kept confidential, not considered for public posting, please explicitly specify that. Unless you state otherwise, I will treat your message as a letter to the editor that I may or may not publish in the feedback section. After that, it will be too late to retract it. If you disagree with something I said, especially when sending an ad-hominem attack, a rant composed mainly of obscenities or a death threat, please quote the offending passage and cite the web page where you found it, tell me why you think it is wrong, and, if possible, provide some supporting evidence. I can’t very well fix erroneous or ambiguous text if I can’t find it.
Your face IP:[18.104.22.168]
|Feedback||You are visitor number 29,880.|