Package java.util.prefs

Examples of java.util.prefs.Preferences.sync()


    static void startupStarted() {
        Preferences prefs = Preferences.userRoot().node("/com/lightcrafts/app");
        prefs.putBoolean(StartupKey, false);
        try {
            prefs.sync();
        }
        catch (BackingStoreException e) {
            System.err.println("Couldn't access Preferences in StartupCrash");
            e.printStackTrace();
        }
View Full Code Here


    {
        ServerSystemPreferences prefs = new ServerSystemPreferences( service );
        Preferences testNode = prefs.node( "testNode" );

        testNode.put( "cn", "testNodeValue" );
        testNode.sync();
    }


    /**
     * Tests the creation and use of a new preferences node.
View Full Code Here

    public void testCreateAndSetBoolean() throws BackingStoreException
    {
        ServerSystemPreferences prefs = new ServerSystemPreferences( service );
        Preferences testNode = prefs.node( "testNode" );
        testNode.putBoolean( "cn", false );
        testNode.sync();
        testNode = prefs.node( "testNode" );
        assertEquals( false, testNode.getBoolean( "cn", false ) );
    }

View Full Code Here

    public void testCreateAndSetDouble() throws BackingStoreException
    {
        ServerSystemPreferences prefs = new ServerSystemPreferences( service );
        Preferences testNode = prefs.node( "testNode" );
        testNode.putDouble( "cn", 3.14 );
        testNode.sync();
        testNode = prefs.node( "testNode" );
        assertTrue( 3.14 == testNode.getDouble( "cn", 9.20 ) );
    }

View Full Code Here

    public void testCreateAndSetFloat() throws BackingStoreException
    {
        ServerSystemPreferences prefs = new ServerSystemPreferences( service );
        Preferences testNode = prefs.node( "testNode" );
        testNode.putFloat( "cn", ( float ) 9.20 );
        testNode.sync();
        testNode = prefs.node( "testNode" );
        assertTrue( ( float ) 9.20 == testNode.getFloat( "cn", ( float ) 9.20 ) );
    }

View Full Code Here

    public void testCreateAndSetInt() throws BackingStoreException
    {
        ServerSystemPreferences prefs = new ServerSystemPreferences( service );
        Preferences testNode = prefs.node( "testNode" );
        testNode.putInt( "cn", 345 );
        testNode.sync();
        testNode = prefs.node( "testNode" );
        assertTrue( 345 == testNode.getInt( "cn", 345 ) );
    }

View Full Code Here

    public void testCreateAndSetLong() throws BackingStoreException
    {
        ServerSystemPreferences prefs = new ServerSystemPreferences( service );
        Preferences testNode = prefs.node( "testNode" );
        testNode.putLong( "cn", 75449559185447L );
        testNode.sync();
        testNode = prefs.node( "testNode" );
        assertTrue( 75449559185447L == testNode.getLong( "cn", 75449559185447L ) );
    }

View Full Code Here

        ServerSystemPreferences prefs = new ServerSystemPreferences( service );
        Preferences testNode = prefs.node( "testNode" );

        testNode.put( "cn", "testNodeValue" );
        testNode.putInt( "roomNumber", 345 );
        testNode.sync();

        testNode = prefs.node( "testNode" );
        assertEquals( 345, testNode.getInt( "roomNumber", 87 ) );
        testNode.remove( "cn" );
        testNode.remove( "roomNumber" );
View Full Code Here

        testNode = prefs.node( "testNode" );
        assertEquals( 345, testNode.getInt( "roomNumber", 87 ) );
        testNode.remove( "cn" );
        testNode.remove( "roomNumber" );
        testNode.sync();

        assertEquals( "no value", testNode.get( "cn", "no value" ) );
        assertEquals( "no value", testNode.get( "roomNumber", "no value" ) );
    }
}
View Full Code Here

        if (value != null)
        {
          pref.put(key, value);
        }
      }
      pref.sync();
    }
    catch (BackingStoreException be)
    {
      throw new ConfigStoreException("Failed to store config" + configPath, be);
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.