本帖最后由 王浩龙 于 2014-3-15 17:29 编辑
- public class ReflectTest2 {
- public static void main(String[] args) throws IOException, InstantiationException, IllegalAccessException, ClassNotFoundException {
- //相对路径是相对谁来说的呢?
- InputStream ips = new FileInputStream("config.propertise");
- Properties props = new Properties();
- props.load(ips);
- ips.close();
- String className = props.getProperty("className");
- Collection collection = (Collection) Class.forName(className).newInstance();
- ReflectPoint pt1 = new ReflectPoint(3, 3);
- ReflectPoint pt2 = new ReflectPoint(5, 3);
- ReflectPoint pt3 = new ReflectPoint(3, 3);
- collection.add(pt1);
- collection.add(pt2);
- collection.add(pt3);
- collection.add(pt1);
- System.out.println(collection.size());
- }
- }
复制代码 我在看张老师的视频时听张老师说把配置文件config.propertise用字节流读取用的是相对路径,这里的相对路径到底相对的是那个呢?希望大家指点一下啊代码如下
|