Code example for AbstractPreferences

Methods: flushnodenodeExistsputBooleanputIntremoveNode

0
            //expected 
        } 
    } 
 
    public void testNodeExists() throws BackingStoreException { 
        AbstractPreferences ap1 = (AbstractPreferences) pref.node("First node");
        AbstractPreferences ap2 = (AbstractPreferences) pref.node("Second node");
        pref.putInt("IntegerValue", 33);
        pref.putBoolean("BoolValue", true);
        pref.flush();
 
        assertTrue(pref.nodeExists("First node"));
        assertTrue(pref.nodeExists("Second node"));
        assertFalse(pref.nodeExists("IntegerValue"));
        assertFalse(pref.nodeExists("BoolValue"));
        assertFalse(pref.nodeExists("Value"));
        assertFalse(pref.nodeExists(nodeName));
 
        try { 
            pref.nodeExists("///invalid");
            fail("IllegalArgumentException expected");
        } catch (IllegalArgumentException e) {
            //expected 
        } 
 
        pref.removeNode();
 
        try { 
            pref.nodeExists("Exception");
            fail("IllegalStateException expected");
        } catch (IllegalStateException e) {
            //expected 
        } 
    } 
Connect your IDE to all the code out there  Get Codota for Java