Java Preference Get getInt(final Class preferencesClass, final String preferenceName)

Here you can find the source of getInt(final Class preferencesClass, final String preferenceName)

Description

get Int

License

Apache License

Declaration

public static int getInt(final Class<?> preferencesClass, final String preferenceName) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.prefs.Preferences;

public class Main {
    public static int getInt(final Class<?> preferencesClass, final String preferenceName) {
        final Preferences preferences = getPreferences(preferencesClass);
        return preferences.getInt(preferenceName, 0);
    }//w w w  .j ava  2 s.  c o  m

    public static Preferences getPreferences(final Class<?> preferencesClass) {
        final String preferenceGroup = preferencesClass.getName();
        return getUserPreferences(preferenceGroup);
    }

    public static Preferences getUserPreferences(final String preferenceGroup) {
        final Preferences userRoot = Preferences.userRoot();
        final Preferences preferences = userRoot.node(preferenceGroup);
        return preferences;
    }
}

Related

  1. getBoolean(final String key, final boolean defaultValue)
  2. getCLOB(Preferences prefs, String key, String def)
  3. getClobStorage(Preferences prefs, String key)
  4. getDefault()
  5. getFloat(String key, Float def)
  6. getList(String path)
  7. getNode(String path)
  8. getPreference(String key, Boolean defaultValue)
  9. getPreferences()