Java Preference userNodeForClass(Class clazz)

Here you can find the source of userNodeForClass(Class clazz)

Description

user Node For Class

License

Apache License

Declaration

private static Preferences userNodeForClass(Class<?> clazz) 

Method Source Code


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

import java.util.prefs.Preferences;

public class Main {
    private static Preferences userNodeForClass(Class<?> clazz) {
        final Preferences prefs = Preferences.userNodeForPackage(clazz);
        return prefs.node(clazz.getSimpleName());
    }/* ww  w  .j a v  a2  s.  com*/

    private static Preferences userNodeForClass(String className) {
        final int pkgEndIndex = className.lastIndexOf('.');
        String packageName = className.substring(0, pkgEndIndex);
        String simpleClassName = className.substring(pkgEndIndex + 1);
        String packagePath = "/" + packageName.replace('.', '/');

        final Preferences prefs = Preferences.userRoot().node(packagePath);
        return prefs.node(simpleClassName);
    }
}

Related

  1. hasEnv(String key, String value)
  2. initEnv(String key, String value)
  3. keyExists(String className, String prefName)
  4. readAllReg(String path)
  5. savePreference(String key, Object value)
  6. writeReg2(String name, String value, Class clazz)