1 Star 0 Fork 0

LiShixi / pim

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
TestPreferences.java 1.08 KB
一键复制 编辑 原始数据 按行查看 历史
LiShixi 提交于 2016-06-06 20:21 . java保存信息到注册表
import java.util.prefs.Preferences;
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author LiShixi
*/
public class TestPreferences {
public static void main(String[] args) {
TestPreferences regtray = new TestPreferences();
String path = "filepath";
regtray.saveFilePath("d:/test/test.dat");
String readFilePath = regtray.readFilePath(path);
System.out.println("readFilePath = " + readFilePath);
}
public String readFilePath(String path) {
Preferences p = Preferences.userNodeForPackage(TestPreferences.class);
String filepath = p.get(path, null);
if (filepath != null) {
System.out.println("filepath=" + filepath);
}
return filepath;
}
public void saveFilePath(String path) {
Preferences p = Preferences.userNodeForPackage(TestPreferences.class);
p.put("filepath", path);
}
}
Java
1
https://gitee.com/loyy77/pim.git
git@gitee.com:loyy77/pim.git
loyy77
pim
pim
master

搜索帮助