개발

자바에서 윈도우 레지스트리 사용하기

에드몽단테스 2007. 9. 28. 10:09
간단한 메소드만 몇개 정리해봤습니다.
이정도면 쓸만하겠죠?

import java.util.prefs.BackingStoreException;
import java.util.prefs.Preferences;

public class Main
{
    private static Preferences pref;
    
    public static void main(String[] args) throws BackingStoreException
    {
        pref = Preferences.userRoot();
    }
    
    public static void setValue(String key, String value)
    {
        pref.put(key, value);
    }
    
    public static String getValue(String key)
    {
        return pref.get(key, null);
    }
    
    public static boolean hasValue(String key)
    {
        return pref.get(key, null) != null;
    }
    
    public static void showKeyValue() throws BackingStoreException
    {
        String[] keys = pref.keys();
        for(int i=0; i             System.out.println("key : "+keys[i]+" value : "+pref.get(keys[i], null));
    }
    
    public static void removeValue(String key)
    {
        pref.remove(key);
    }
}
반응형