标签:
package com.lovo.cunwenjian;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Properties;
import java.util.Set;
public class Cunwenjian {
public static void main(String[] args) {
// TODO Auto-generated method stub
Properties props = new Properties();
props.setProperty("NOT1", "娜娜");
props.setProperty("NOT2", "二硕");
props.setProperty("NOT3", "贤贤");
props.setProperty("NOT4", "歌哥");
props.setProperty("NOT5", "欧巴");
System.out.println(props.size());
System.out.println("================================");
Set allkey = props.keySet();
for (Object key : allkey) {
System.out.println(key);
System.out.println("================================");
}
System.out.println(props.getProperty("NOT1"));
System.out.println("================================");
try { props.store(new FileOutputStream("data.properties"), null);
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
标签:
原文地址:http://www.cnblogs.com/-xhx/p/5598836.html