📄 e407. determining if a preference node contains a specific value.txt
字号:
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 + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -