Shiv Tattva wrote:
But can somebody please explain the below code in layman's terms ?
I'm finding it hard to think of how to explain what it does without just quoting the
java.util.prefs.Preferences documentation.
Preferences abstract a hierarchical implementation dependent persistence mechanism with a per-user and system wide root. A user node is independent of a system node and of another system user's user node.
Nodes have a root (path "/") and child paths. You can specify a path as a slash delimited
String or have it defined by a class' package where '.' will be replaced with '/'. Parent nodes of a path are created if they do not already exist.
If you use suggested package naming conventions and the packaged based node look-up, you can expect to have your node to yourself and not have other code messing with your preferences. You are also free to make up your own unique path using the node(String pathname) method.
If two bits of code using Preferences share the same node and have different concepts of what should be stored in a key, you get unexpected results. If they have the same concept, it can be a nice way to reference common information.
There are times, like when troubleshooting on a target system, that it can be nice to know how it stores the data or at least where it is stored. You can find articles about that on the Internet with searches like
java preferences mac if you wanted to know for the Mac OS.