Skip to content

Commit c4c9d94

Browse files
committed
modified src/org/csource/common/IniFileReader.java
1 parent 7332ac5 commit c4c9d94

File tree

1 file changed

+67
-38
lines changed

1 file changed

+67
-38
lines changed

src/org/csource/common/IniFileReader.java

Lines changed: 67 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -136,52 +136,81 @@ private void loadFromFile(String conf_filename) throws FileNotFoundException, IO
136136
String value;
137137
Object obj;
138138
ArrayList valueList;
139-
140-
fReader = new FileReader(conf_filename);
141-
buffReader = new BufferedReader(fReader);
139+
InputStream is=null;
140+
// fReader = new FileReader(conf_filename);
141+
// buffReader = new BufferedReader(fReader);
142142
this.paramTable = new Hashtable();
143143

144144
try
145145
{
146-
while ((line=buffReader.readLine()) != null)
147-
{
148-
line = line.trim();
149-
if (line.length() == 0 || line.charAt(0) == '#')
150-
{
151-
continue;
152-
}
153-
154-
parts = line.split("=", 2);
155-
if (parts.length != 2)
156-
{
157-
continue;
158-
}
159-
160-
name = parts[0].trim();
161-
value = parts[1].trim();
146+
// while ((line=buffReader.readLine()) != null)
147+
// {
148+
// line = line.trim();
149+
// if (line.length() == 0 || line.charAt(0) == '#')
150+
// {
151+
// continue;
152+
// }
153+
//
154+
// parts = line.split("=", 2);
155+
// if (parts.length != 2)
156+
// {
157+
// continue;
158+
// }
159+
is = Thread.currentThread().getContextClassLoader().getResourceAsStream(conf_filename);
160+
// System.out.println(conf_filename+"========================================");
161+
Properties props = new Properties();
162+
props.load(is);
163+
Iterator<Map.Entry<Object, Object>> it = props.entrySet().iterator();
164+
while (it.hasNext()) {
165+
Map.Entry<Object, Object> entry = it.next();
166+
name= entry.getKey().toString();
167+
value = entry.getValue().toString();
168+
// System.out.println(name+"======================================");
169+
obj = this.paramTable.get(name);
170+
if (obj == null)
171+
{
172+
this.paramTable.put(name, value);
173+
}
174+
else if (obj instanceof String)
175+
{
176+
valueList = new ArrayList();
177+
valueList.add(obj);
178+
valueList.add(value);
179+
this.paramTable.put(name, valueList);
180+
}
181+
else
182+
{
183+
valueList = (ArrayList)obj;
184+
valueList.add(value);
185+
}
186+
}
187+
// name = parts[0].trim();
188+
// value = parts[1].trim();
162189

163-
obj = this.paramTable.get(name);
164-
if (obj == null)
165-
{
166-
this.paramTable.put(name, value);
167-
}
168-
else if (obj instanceof String)
169-
{
170-
valueList = new ArrayList();
171-
valueList.add(obj);
172-
valueList.add(value);
173-
this.paramTable.put(name, valueList);
174-
}
175-
else
176-
{
177-
valueList = (ArrayList)obj;
178-
valueList.add(value);
179-
}
180-
}
190+
// obj = this.paramTable.get(name);
191+
// if (obj == null)
192+
// {
193+
// this.paramTable.put(name, value);
194+
// }
195+
// else if (obj instanceof String)
196+
// {
197+
// valueList = new ArrayList();
198+
// valueList.add(obj);
199+
// valueList.add(value);
200+
// this.paramTable.put(name, valueList);
201+
// }
202+
// else
203+
// {
204+
// valueList = (ArrayList)obj;
205+
// valueList.add(value);
206+
// }
207+
// }
181208
}
182209
finally
183210
{
184-
fReader.close();
211+
if (is!=null)
212+
is.close();
213+
// fReader.close();
185214
}
186215
}
187216
}

0 commit comments

Comments
 (0)