InputStream ips=test1.class.getClassLoader().getResourceAsStream("cofig.ini");//new FileInputStream("src/beforeHeiMa/cofig.ini");
Properties pro=new Properties();
pro.load(ips);
ips.close();
String className=pro.getProperty("className");
Collection collection=(Collection)Class.forName(className).newInstance();
Person p1=new Person();
Person p2=new Person();
Person p3=new Person();
collection.add(p1);
collection.add(p2);
collection.add(p3);
System.out.println(collection.size());
不知道错那礼了,对于绝对路径和相对路径理解不太清楚 |