package IODemo;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.util.Properties;
public class PropertiesDemo {
public static void main(String[] args) throws Exception{
method();
}
public static void method ()throws Exception{
//创建字节输入流
FileInputStream file = new FileInputStream("/Users/Desktop/IOPrctice/Properties.txt");
//创建Properties类
Properties per = new Properties();
//加载类中的键值对
per.load(file);
//关闭输入流
file.close();
System.out.println(per);
//修改对应键的值
per.setProperty("Name","zhangsan");
//创建字节输入流
FileOutputStream fos = new FileOutputStream("/Users/Desktop/IOPrctice/Properties.txt");
//使用Properties 集合方法存储
per.store(fos,"123");
//关闭流
fos.close();
}
}