diff --git a/src/org/csource/common/IniFileReader.java b/src/org/csource/common/IniFileReader.java index 966f180..e4e7b68 100644 --- a/src/org/csource/common/IniFileReader.java +++ b/src/org/csource/common/IniFileReader.java @@ -136,52 +136,81 @@ public class IniFileReader String value; Object obj; ArrayList valueList; - - fReader = new FileReader(conf_filename); - buffReader = new BufferedReader(fReader); + InputStream is=null; +// fReader = new FileReader(conf_filename); +// buffReader = new BufferedReader(fReader); this.paramTable = new Hashtable(); try { - while ((line=buffReader.readLine()) != null) - { - line = line.trim(); - if (line.length() == 0 || line.charAt(0) == '#') - { - continue; - } +// while ((line=buffReader.readLine()) != null) +// { +// line = line.trim(); +// if (line.length() == 0 || line.charAt(0) == '#') +// { +// continue; +// } +// +// parts = line.split("=", 2); +// if (parts.length != 2) +// { +// continue; +// } + is = Thread.currentThread().getContextClassLoader().getResourceAsStream(conf_filename); +// System.out.println(conf_filename+"========================================"); + Properties props = new Properties(); + props.load(is); + Iterator> it = props.entrySet().iterator(); + while (it.hasNext()) { + Map.Entry entry = it.next(); + name= entry.getKey().toString(); + value = entry.getValue().toString(); +// System.out.println(name+"======================================"); + obj = this.paramTable.get(name); + if (obj == null) + { + this.paramTable.put(name, value); + } + else if (obj instanceof String) + { + valueList = new ArrayList(); + valueList.add(obj); + valueList.add(value); + this.paramTable.put(name, valueList); + } + else + { + valueList = (ArrayList)obj; + valueList.add(value); + } + } +// name = parts[0].trim(); +// value = parts[1].trim(); - parts = line.split("=", 2); - if (parts.length != 2) - { - continue; - } - - name = parts[0].trim(); - value = parts[1].trim(); - - obj = this.paramTable.get(name); - if (obj == null) - { - this.paramTable.put(name, value); - } - else if (obj instanceof String) - { - valueList = new ArrayList(); - valueList.add(obj); - valueList.add(value); - this.paramTable.put(name, valueList); - } - else - { - valueList = (ArrayList)obj; - valueList.add(value); - } - } +// obj = this.paramTable.get(name); +// if (obj == null) +// { +// this.paramTable.put(name, value); +// } +// else if (obj instanceof String) +// { +// valueList = new ArrayList(); +// valueList.add(obj); +// valueList.add(value); +// this.paramTable.put(name, valueList); +// } +// else +// { +// valueList = (ArrayList)obj; +// valueList.add(value); +// } +// } } finally { - fReader.close(); + if (is!=null) + is.close(); +// fReader.close(); } } }