Here you can find the source of keyExists(String className, String prefName)
static boolean keyExists(String className, String prefName)
//package com.java2s; //License from project: Apache License import java.util.prefs.Preferences; public class Main { /**/*from w w w . j a v a 2 s. co m*/ * note that this method is not guaranteed to return an accurate answer if * the key in question is nullable. */ static boolean keyExists(String className, String prefName) { final Preferences prefs = userNodeForClass(className); return prefs.get(prefName, null) != null; } private static Preferences userNodeForClass(Class<?> clazz) { final Preferences prefs = Preferences.userNodeForPackage(clazz); return prefs.node(clazz.getSimpleName()); } private static Preferences userNodeForClass(String className) { final int pkgEndIndex = className.lastIndexOf('.'); String packageName = className.substring(0, pkgEndIndex); String simpleClassName = className.substring(pkgEndIndex + 1); String packagePath = "/" + packageName.replace('.', '/'); final Preferences prefs = Preferences.userRoot().node(packagePath); return prefs.node(simpleClassName); } }