e407. determining if a preference node contains a specific value.txt
来自「这里面包含了一百多个JAVA源文件」· 文本 代码 · 共 20 行
TXT
20 行
This example enumerates the key/value pairs in a preference node and checks each value for a match.
// Returns the key of a preference whose value matches the specified value;
// null is returned if no such key exists.
public static String containsValue(Preferences node, String value) {
try {
// Get all the keys
String[] keys = node.keys();
// Scan the keys
for (int i=0; i<keys.length; i++) {
if (value.equals(node.get(keys[i], null))) {
return keys[i];
}
}
} catch (BackingStoreException e) {
}
return null;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?