Here you can find the source of getBoolean(final String key, final boolean defaultValue)
Parameter | Description |
---|---|
key | the string used to save the boolean to be retrieved |
defaultValue | the value to be returned in case an error is encountered |
defaultValue
otherwise
public static boolean getBoolean(final String key, final boolean defaultValue)
//package com.java2s; //License from project: Open Source License import java.util.prefs.Preferences; public class Main { /**/*from w w w . j a va2 s .c o m*/ * The preferences node to load/save from/to */ private static final Preferences prefs = Preferences.userRoot().node("/edu/colostate/vchill"); /** * Gets a boolean value from the preferences object * * @param key the string used to save the boolean to be retrieved * @param defaultValue the value to be returned in case an error is encountered * @return the stored value if possible, <code>defaultValue</code> otherwise */ public static boolean getBoolean(final String key, final boolean defaultValue) { try { return prefs.getBoolean(key, defaultValue); } catch (Exception e) { return defaultValue; } } }