Java Preference Get getUserPrefsNode(Object mainClassInstance)

Here you can find the source of getUserPrefsNode(Object mainClassInstance)

Description

Gets the Preferences node for a package, given one class in the package (either by reference or by reference to its Class object).

License

Apache License

Parameter

Parameter Description
mainClassInstance Either the object, or the object's Class object.

Declaration

public static Preferences getUserPrefsNode(Object mainClassInstance) 

Method Source Code


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

import java.util.prefs.Preferences;

public class Main {
    /**// w  w w .j  a  v  a 2  s .  c om
     * Gets the Preferences node for a package, given one class in the package
     * (either by reference or by reference to its Class object).
     *
     * @param mainClassInstance Either the object, or the object's Class object.
     */
    public static Preferences getUserPrefsNode(Object mainClassInstance) {
        Class clazz;
        if (mainClassInstance instanceof Class)
            clazz = (Class) mainClassInstance;
        else
            clazz = mainClassInstance.getClass();
        return Preferences.userNodeForPackage(clazz);
    }
}

Related

  1. getPrefsStrings(Preferences prefs, String key)
  2. getStringArray(final String key, final String[] defaultValue)
  3. getUserPreferences()
  4. getUserPreferences()
  5. getUserPreferences(final String preferenceGroup)