Java 8 Preferences - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Preferences class.

This code example shows how to use the following methods: get, put
        set("autoShow", value);
    } 
 
 
    private void set(String name, String value) {
        String old = applicationPreferences.get(name, "");
        applicationPreferences.put(name, value);
        savePreferences(); 
        propSupport.firePropertyChange(name, old, value);
    } 
 
    private void set(String name, int value) {
        int old = applicationPreferences.getInt(name, 0);
        applicationPreferences.putInt(name, value);
        savePreferences(); 
        propSupport.firePropertyChange(name, old, value);
    } 
 
    private void set(String name, boolean value) {
        boolean old = applicationPreferences.getBoolean(name, false);
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getBoolean, getInt, putDouble
      assert false; 
    } 
    PreferencesExt prefs = store.getPreferences();
 
    Preferences node = prefs.node("/myApp");
    int ival  = node.getInt("extraOne", 0);
    assert ival == 1 : "testStandardChain fail 1 " + ival;
 
    ival  = node.getInt("extraTwo", 0);
    assert ival == 2 : "testStandardChain fail 2 " + ival;
 
    ival  = node.getInt("num_rows", 0);
    assert ival == 128 : "testStandardChain fail 3 " + ival;
 
    ival  = node.getInt("missing", 0);
    assert ival == 0 : "testStandardChain fail 4 " + ival;
 
    boolean bval  = node.getBoolean("TestBoolean", false);
    assert bval: "testStandardChain fail 5 " + bval;
 

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getInt
     * 
     * @param prefs object representing persistent Preferences. 
     */ 
    public void restoreFrom(Preferences prefs)
    { 
        setTopActivity(prefs.getInt(KEY_TOP_ACTIVITY, DEFAULT_TOP_ACTIVITY));
        setTopHighlights(prefs.getInt(KEY_TOP_HIGHLIGHTS, DEFAULT_TOP_HIGHLIGHTS));
 
        setActivityWeight(prefs.getInt(KEY_ACTIVITY_WEIGHT, DEFAULT_ACTIVITY_WEIGHT));
        setInlinksWeight(prefs.getInt(KEY_INLINKS_WEIGHT, DEFAULT_INLINKS_WEIGHT));
        setClickthroughsWeight(prefs.getInt(KEY_CLICKTHROUGHS_WEIGHT, DEFAULT_CLICKTHROUGHS_WEIGHT));
        setFeedViewsWeight(prefs.getInt(KEY_FEED_VIEWS_WEIGHT, DEFAULT_FEED_VIEWS_WEIGHT));
    } 
 
    /** 
     * Write all the preferences from this Object to persistent preferences. On Windows, this is the 
     * registry. 
     * 
     * @param prefs object representing persistent Preferences. 
     */ 
Full Snippet Info
6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: put, putBoolean, putByteArray, putDouble, putFloat
      barr[1] = 2;
      barr[2] = 3;
      prefs.putByteArray("testBA", barr);
 
      Preferences subnode = prefs.node("SemperUbi");
      subnode.putDouble("testD", 3.14158);
      subnode.putFloat("testF", 1.23457F);
      subnode.putLong("testL", 12345678901L);
      subnode.putInt("testI", 123456780);
      subnode.put("testS", "youdBeLivebyNow");
      subnode.putBoolean("testB", false);
 
      byte[] barr2 = new byte[3];
      barr2[0] = 2;
      barr2[1] = 3;
      barr2[2] = 4;
      subnode.putByteArray("testBA", barr2);
 
      store.save();
    } catch (Exception e) {

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: getBoolean, getInt, getLong, putBoolean, sync
     * flag. 
     * @return Returns <code>true</code> only if an update is available. 
     */ 
    private static boolean isUpdateAvailable( boolean reset ) {
        try { 
            if ( m_prefs.getBoolean( IS_UPDATE_AVAILABLE_KEY, false ) ) {
                if ( reset ) {
                    m_prefs.putBoolean( IS_UPDATE_AVAILABLE_KEY, false );
                    syncPrefs(); 
                } 
                return true; 
            } 
        } 
        catch ( IllegalStateException e ) {
            // ignore? 
        } 
        return false; 
    } 
 
    /** 

6
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 Preferences Questions & Answers:

See Code Examples for Java 8 Preferences Methods: