public class 访问配置文件 {
public static void main(String[] args)throws Exception {
//FootballStar f=new FootballStar();
//BasketStar b=new BasketStar();
FileInputStream fis=new FileInputStream("d:\\config.properties");
Properties p=new Properties();
p.load(fis);
String className=p.getProperty("className");
String methodName=p.getProperty("methodName");
System.out.println(className+methodName);
Class clazz=Class.forName(className);
Object obj=clazz.newInstance();
Method m=clazz.getMethod(methodName);
m.invoke(obj);
}
} |