⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e413. retrieving a preference node.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
A preference node can be retrieved using a Class object or by a string. When using a Class object to retrieve a preference node, the package containing the Class object identifies the node. 
It is important to note that these methods also automatically create the node if it doesn't exist. Since nodes take up resources, even when empty, you should avoid creating unnecessary nodes. See e415 Determining If a Preference Node Exists for information on how to avoid creating nodes. 

The string used to retrieve a preference node is called a path and resembles a file path. For example, the path for the preference node associated with the package com.mycompany is /com/mycompany. 

Paths that begin with `/' are absolute paths. A relative path can be specified (one that does not begin with `/') and is treated relative to another preference node. For example, if you use the node at /javax/swing to retrieve another node with the path text/html, the node at /javax/swing/text/html is returned. 

    // System preference nodes
    
    // Use a Class
    Preferences prefs = Preferences.systemNodeForPackage(java.lang.String.class);
    
    // Use an absolute path
    prefs = Preferences.systemRoot().node("/java/lang/String");
    
    // Use a relative path
    prefs = Preferences.systemRoot().node("/javax/swing");
    prefs = prefs.node("text/html");
    
    // User preference nodes
    
    // Use a class
    prefs = Preferences.userNodeForPackage(com.mycompany.MyClass.class);
    
    // Use an absolute path
    prefs = Preferences.userRoot().node("/com/mycompany");
    
    // Use a relative path
    prefs = Preferences.userRoot().node("/javax/swing");
    prefs = prefs.node("text/html");

 Related Examples 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -