Package java.util.prefs

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


    try {
      initialDir = userPrefs.get("dir", null);
      if (initialDir == null) {
        initialDir = System.getProperty("user.home");
        userPrefs.put("dir", initialDir);
        userPrefs.sync();
      }
    } catch (BackingStoreException exc) {
      userPrefs = null;
      initialDir = System.getProperty("user.home");
    }
View Full Code Here


      }
    }
    if (dir != null) {
      userPrefs.put("dir", dir.getAbsolutePath());
      try {
        userPrefs.sync();
      } catch (BackingStoreException exc) {
      }
    }

    boolean fileAdded = false;
View Full Code Here

    public void testCreate() throws BackingStoreException
    {
        Preferences testNode = prefs.node( "testNode" );

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


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

    public void testCreateAndSet() throws BackingStoreException
    {
        Preferences testNode = prefs.node( "testNode" );

        testNode.put( "testNodeKey", "testNodeValue" );
        testNode.sync();

        testNode.putBoolean( "boolKey", true );
        testNode.putByteArray( "arrayKey", new byte[10] );
        testNode.putDouble( "doubleKey", 3.14 );
        testNode.putFloat( "floatKey", ( float ) 3.14 );
View Full Code Here

        testNode.putByteArray( "arrayKey", new byte[10] );
        testNode.putDouble( "doubleKey", 3.14 );
        testNode.putFloat( "floatKey", ( float ) 3.14 );
        testNode.putInt( "intKey", 345 );
        testNode.putLong( "longKey", 75449559185447L );
        testNode.sync();

        testNode = prefs.node( "testNode" );

        assertEquals( true, testNode.getBoolean( "boolKey", false ) );
        assertTrue( 3.14 == testNode.getDouble( "doubleKey", 9.20 ) );
View Full Code Here

    public void testCreateAndRemove() throws BackingStoreException
    {
        Preferences testNode = prefs.node( "testNode" );

        testNode.put( "testNodeKey", "testNodeValue" );
        testNode.sync();

        testNode.putBoolean( "boolKey", true );
        testNode.putByteArray( "arrayKey", new byte[10] );
        testNode.putDouble( "doubleKey", 3.14 );
        testNode.putFloat( "floatKey", ( float ) 3.14 );
View Full Code Here

        testNode.putByteArray( "arrayKey", new byte[10] );
        testNode.putDouble( "doubleKey", 3.14 );
        testNode.putFloat( "floatKey", ( float ) 3.14 );
        testNode.putInt( "intKey", 345 );
        testNode.putLong( "longKey", 75449559185447L );
        testNode.sync();

        testNode = prefs.node( "testNode" );

        assertEquals( true, testNode.getBoolean( "boolKey", false ) );
        assertTrue( 3.14 == testNode.getDouble( "doubleKey", 9.20 ) );
View Full Code Here

        testNode.remove( "arrayKey" );

        assertEquals( "no value", testNode.get( "doubleKey", "no value" ) );
        assertEquals( "no value", testNode.get( "arrayKey", "no value" ) );

        testNode.sync();

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

    updatePreferences(preferences, "tripUpdatesUrl", model.getTripUpdatesUrl());
    updatePreferences(preferences, "vehiclePositionsUrl",
        model.getVehiclePositionsUrl());
    updatePreferences(preferences, "alertsUrl", model.getAlertsUrl());
    try {
      preferences.sync();
    } catch (BackingStoreException e) {
      e.printStackTrace();
    }
  }
View Full Code Here

    }

    public static void clearMessages() throws BackingStoreException {
        Preferences prefs = Preferences.userNodeForPackage(BeforeAfterParent.class);
        prefs.clear();
        prefs.sync();
    }

    public static void addMessage(String message) {
        Preferences prefs = Preferences.userNodeForPackage(BeforeAfterParent.class);
        int numMessages = prefs.getInt("numMessages", 0);
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.