From c4c9d94656ccd0e52a4481a32fea6d666c0e0157 Mon Sep 17 00:00:00 2001 From: mengpengfei <810679402@qq.com> Date: Fri, 14 Apr 2017 15:55:23 +0800 Subject: [PATCH 1/3] modified src/org/csource/common/IniFileReader.java --- src/org/csource/common/IniFileReader.java | 105 ++++++++++++++-------- 1 file changed, 67 insertions(+), 38 deletions(-) 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(); } } } From c47129c3ad70ed91cf78bba8e8c6b85522202155 Mon Sep 17 00:00:00 2001 From: mengpengfei <810679402@qq.com> Date: Fri, 14 Apr 2017 16:07:16 +0800 Subject: [PATCH 2/3] modified src/org/csource/common/IniFileReader.java --- src/org/csource/common/IniFileReader.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/org/csource/common/IniFileReader.java b/src/org/csource/common/IniFileReader.java index e4e7b68..bcb35dd 100644 --- a/src/org/csource/common/IniFileReader.java +++ b/src/org/csource/common/IniFileReader.java @@ -128,10 +128,11 @@ public class IniFileReader private void loadFromFile(String conf_filename) throws FileNotFoundException, IOException { - FileReader fReader; - BufferedReader buffReader; - String line; - String[] parts; + //修改人 孟鹏飞,问题说明 使用中发现原来客户端打jar包后,在另一个项目中引用,另一个项目打jar包后运行时找不到客户端配置文件 + // FileReader fReader; + // BufferedReader buffReader; + // String line; + // String[] parts; String name; String value; Object obj; From 560e831f0baae925547fb5c87ecb00bd650a82c5 Mon Sep 17 00:00:00 2001 From: mengpengfei <810679402@qq.com> Date: Fri, 14 Apr 2017 16:08:30 +0800 Subject: [PATCH 3/3] modified src/org/csource/common/IniFileReader.java --- src/org/csource/common/IniFileReader.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/org/csource/common/IniFileReader.java b/src/org/csource/common/IniFileReader.java index bcb35dd..3515802 100644 --- a/src/org/csource/common/IniFileReader.java +++ b/src/org/csource/common/IniFileReader.java @@ -128,7 +128,7 @@ public class IniFileReader private void loadFromFile(String conf_filename) throws FileNotFoundException, IOException { - //修改人 孟鹏飞,问题说明 使用中发现原来客户端打jar包后,在另一个项目中引用,另一个项目打jar包后运行时找不到客户端配置文件 + //修改人 孟鹏飞,问题说明 使用中发现原来客户端打jar包后,在另一个项目中引用,另一个项目打jar包后运行时找不到客户端配置文件 ,能不能把我名字加上,以后好找工作 // FileReader fReader; // BufferedReader buffReader; // String line;