package com.market.util;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
public class ObjectFactory {
public static HashMap<String, Object> objects = new HashMap<String, Object>();
static {
BufferedReader reader = new BufferedReader(new InputStreamReader(
ObjectFactory.class.getClassLoader().getResourceAsStream(
"Object")));
String row = null;
try {
while ((row = reader.readLine()) != null) {
try {
objects.put(row.split("=")[0], Class.forName(row.split("=")[1]).newInstance());
} catch (InstantiationException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
版权归属:
王小木人个人技术文章记录
许可协议:
本文使用《署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)》协议授权
评论区