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;
}
阅读(827) | 评论(0) | 转发(0) |