Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Settings and configuration data inside a NetBeans Platform application is preferably saved and loaded via the Java Preferences API. The Java Platform specifies an interface via the Preferences class. With this interface, settings and configuration data can be saved and loaded independent of their physical location. Different implementations can be provided with which the data, for example, in a file, in a system registry or even in a database can be saved. The data is saved in a hierarchic structure in form of key value pairs. An instance of the Preferences class represents a node in this hierarchy. You can imagine a node like a directory in a file system below which the data can be saved.
With the NbPreferences class the Utilities API makes available an implementation of the Java Preferences specification for the NetBeans Platform. This implementation ensures that the settings are stored in the central configuration directory of the application, which is located in the user directory. The settings are stored as normal .properties files. Thus, the settings, which you save via Preferences, like all other settings in a NetBeans Platform application, are managed user-specifically. The NbPreferences class provides two static methods. With the forModule() method a Preferences Node is delivered whose data are saved in a separate .properties file in the config/Preferences directory for each module (see Figure 20-3). With the root() method an application global Preferences Node which manages its data in the config/Preferences.properties file is delivered.