问题3:为什么我编写的类在bin里面,但是Java提示找不到文件
注:我配置文件和类放在同一个包中了
import java.io.*;
import java.util.*;
public class ReflectFrame {
public static void main(String[] args) throws Exception{
InputStream ips=new FileInputStream("config.properties");
Properties prop=new Properties();
prop.load(ips);
ips.close();
String className=prop.getProperty("className");
Collection c=(Collection)Class.forName(className).newInstance();
c.add("a");
c.add("mno");
System.out.println(c.size());
}
}
Exception in thread "main" java.io.FileNotFoundException: config.properties (系统找不到指定的文件。)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at reflected.ReflectFrame.main(ReflectFrame.java:7)
|