Search code examples
javawindowspreferencesregedit

Using Preferences API to save path?


I'm trying use Preferences API to save a path to file in regedit. It is works but the value of path is not saved correctly.

I'm trying this.

public class ImageLogoPreference {

    private final String path = "configs";        
    private Preferences node;

    public ImageLogoPreference(){        
        node = Preferences.userRoot().node(path);
    }

    public void setImageLogo(){                
        node.put("logo", "\\IguanaSistemas\\IguanaFight\\imagens\\logo.png");
    }

    public String getImageLogo(){
        String logo = node.get("logo", "image");
        return logo;
    }    

}

At register save this: ///Iguana/Sistemas///Iguana/Fight//imagens//logo.png

enter image description here Any idea ?


Solution

  • Doesn't matter.

    Just get it in your Java program. You don't have a problem.

        Preferences node =  Preferences.userRoot().node("config");
        //node.put("logo", "\\IguanaSistemas\\IguanaFight\\imagens\\logo.png");
        String s = node.get("logo", "blah");
        System.out.println(s);
    

    Prints the correct string.