BufferedReader br=new BufferedReader(new FileReader("config.txt"));
String line=br.readLine();
System.out.println(line);
Class clazz=Class.forName(line);//为什么我再读取配置文件的内容时,把line放在类加载中会报Exception in thread "main" java.lang.ClassNotFoundException:
//但如果直接写路径就正常,别人的就行,为什么我的不行呢!!
Constructor construct=clazz.getConstructor(String.class,int.class);
Person p=(Person)construct.newInstance("lisi",8);
p.show(); |