应用程序首选项存储
属性映射:
保存至文件中
Properties settins=new Properties();
settins.put("name","good");
FileOutputStream fout=null;
try {
fout = new FileOutputStream("setting.properties");
settins.store(fout, "this is a command");
fout.close();
}
catch (FileNotFoundException e) {e.printStackTrace();}
catch (IOException e) {e.printStackTrace();}
从文件中读取
FileInputStream fin=null;
try {
fin=new FileInputStream("setting.properties");
settins.load(fin);
String name=settins.getProperty("name","default");
System.out.println("name:"+name);
}
catch (FileNotFoundException e) {e.printStackTrace();}
catch (IOException e){e.printStackTrace();}
JAR 文件:
暂无。跳过ing。。。
Java Web Strart:
暂无。跳过阅读ing。。。
Applet:
同楼上
版权声明:本文为博主原创文章,未经博主允许不得转载。