Read/write to Windows registry using Java

前端 未结 24 1634
日久生厌
日久生厌 2020-11-21 05:45

How is it possible to read/write to the Windows registry using Java?

24条回答
  •  無奈伤痛
    2020-11-21 06:24

    I prefer using java.util.prefs.Preferences class.

    A simple example would be

    // Write Operation
    Preferences p = Preferences.userRoot();
    p.put("key","value"); 
    // also there are various other methods such as putByteArray(), putDouble() etc.
    p.flush();
    //Read Operation
    Preferences p = Preferences.userRoot();
    String value = p.get("key");
    

提交回复
热议问题