Mega Code Archive

 
Categories / Java Tutorial / Development
 

Determining If a Preference Node Exists

import java.util.prefs.Preferences; public class Main {   public static void main(String[] argv) throws Exception {     boolean exists = Preferences.userRoot().nodeExists("/yourValue"); // false     Preferences.userRoot().node("/yourValue");     exists = Preferences.userRoot().nodeExists("/yourValue"); // true     Preferences prefs = Preferences.userRoot().node("/yourValue");     prefs.removeNode();     // exists = prefs.nodeExists("/yourValue");     exists = prefs.nodeExists(""); // false   } }