美文网首页
3.01.Properties类

3.01.Properties类

作者: RockyLuo_290f | 来源:发表于2019-01-09 05:26 被阅读0次

继承于hashtable,是线程安全的键值对存储结构

可保存在流中或从流中加载

只能保存字符串的键值对

public static void main(String[] args){
  Properties prop = new Properties();

  prop.setProperty("name", "zhangsan");
  prop.setProperty("age", "10");
}

将Properties存入到文件中


PrintWriter pw = null;
try{
  pw = new printWriter("out.txt");
  prop.list(pw);
}catch(IOException e){
  e.printStackTrace();
}finally{
  if(pw != null){
    pw.close();
  }
}

相关文章

网友评论

      本文标题:3.01.Properties类

      本文链接:https://www.haomeiwen.com/subject/nxairqtx.html