InputStream is =null;//
//is = new FileInputStream("config.properties");//此文件必须放在工程目录下
//is = ReflectTest.class.getResourceAsStream("config.properties");//放在对应包下
//is = ReflectTest.class.getClassLoader().getResourceAsStream("com/saly/java/config.properties");//放在对应包下
Properties props = new Properties();
props.load(is);
props.clone();//必须关闭释放资源
String className = props.getProperty("className");
//通过反射创建对象
Collection collection = (Collection)Class.forName(className).newInstance();//new HashSet<ReflectPoint>();