package com.itcast.demo04.Prop;
import jdk.internal.util.xml.impl.ReaderUTF8;
import sun.nio.cs.UTF_32;
import sun.nio.cs.ext.GBK;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;
/**
* @author newcityman
* @date 2019/7/28 - 12:50
*/
public class Demo01Properties {
public static void main(String[] args) throws IOException {
// show01();
// show02();
show03();
}
private static void show03() throws IOException {
Properties prop = new Properties();
prop.load(new FileReader("day18_IOAndProperties\\prop.txt"));
Set<String> key = prop.stringPropertyNames();
for (String s : key) {
String value = prop.getProperty(s);
System.out.println(s+"==>"+value);
}
}
private static void show02() throws IOException {
Properties prop = new Properties();
prop.setProperty("张曼玉","16");
prop.setProperty("张学友","20");
prop.setProperty("刘德华","18");
FileWriter fw = new FileWriter("day18_IOAndProperties\\prop.txt");
prop.store(fw, "data");
}
private static void show01() {
Properties prop = new Properties();
prop.setProperty("zmy","12");
prop.setProperty("zyy","20");
prop.setProperty("lm","15");
prop.setProperty("zgh","16");
Set<String> strings = prop.stringPropertyNames();
for (String key : strings) {
String value = prop.getProperty(key);
System.out.println(key+"====>"+value);
}
}
}