Chinaunix首页 | 论坛 | 博客
  • 博客访问: 218151
  • 博文数量: 67
  • 博客积分: 2510
  • 博客等级: 少校
  • 技术积分: 890
  • 用 户 组: 普通用户
  • 注册时间: 2008-01-17 09:42
文章分类

全部博文(67)

文章存档

2010年(5)

2009年(7)

2008年(55)

我的朋友

分类: Java

2008-11-18 08:48:21

 private static Properties load(String file, String charset) throws IOException {
  BufferedReader br = new BufferedReader(new InputStreamReader(
    new FileInputStream(file), charset));
  String temp = null;
  temp = br.readLine();
  Properties hostInfo = new Properties();
  while ((temp = br.readLine()) != null) {
   if (!temp.matches("#.*|\\s*")) {
    String[] property = temp.split("(?<=^(?:[^=]*))=");
    if(property.length==2)
    {
     hostInfo.setProperty(property[0], property[1]);
    }
   }
  }
  return hostInfo;
 }
阅读(809) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~