public void setProp(String value,String name,String path)throws IOException{//写入属性文件
Properties pro=new Properties();
pro.setProperty(value,name);
try{
FileOutputStream fos=new FileOutputStream(path);
pro.store(fos,"style pro");
}
catch(IOException e){
e.printStackTrace();
}
}
Properties pro=new Properties();
pro.setProperty(value,name);
try{
FileOutputStream fos=new FileOutputStream(path);
pro.store(fos,"style pro");
}
catch(IOException e){
e.printStackTrace();
}
}
本文介绍了一个简单的Java程序示例,展示了如何使用Properties类将键值对写入属性文件。通过创建Properties实例并调用setProperty方法设置属性,之后使用FileOutputStream打开目标文件,并通过store方法将属性保存到文件中。
1699

被折叠的 条评论
为什么被折叠?



