对于Windows平台就是操作注册表了, 下面就可以操作注册表了更多请参考jdkapi帮助文档
import java.io.*;
import java.util.prefs.*;
public PrefsDemo {
public void (String args)
{
String keys = {"key1","key2","key3"};
String values = {"value1","value2","value3"};
Preferences prefsdemo = Preferences.userRoot.node("test1/test1sub1");
/* 储存参数项*/
for ( i=0 ; i < keys.length; i)
{
prefsdemo.put(keys[i], values[i]);
}
/*清除注册表中参数项*/
{
prefsdemo.removeNode;
}
catch (BackingStoreException e)
{}
/* 导出到XML文件 */
try
{
FileOutputStream fos = FileOutputStream("prefsdemo.xml");
prefsdemo.exportNode(fos);
} catch (Exception e)
{
.err.prln("Cannot export nodes: " + e);
}
}
}
最新评论