- <div class="blockcode"><blockquote>package com.java.day1;
- import java.io.FileInputStream;
- import java.io.InputStream;
- import java.util.Collection;
- import java.util.HashSet;
- import java.util.Properties;
- public class ReflectTest2 {
- /**
- * @param args
- * @throws Exception
- */
- public static void main(String[] args) throws Exception {
- // TODO Auto-generated method stub
- InputStream ips = new FileInputStream("config.properties");
- Properties props = new Properties();
- props.load(ips);
- ips.close();
- String className = props.getProperty("className");
- Collection collections = (Collection)Class.forName(className).newInstance();
- //Collection collections = new HashSet();
- ReflectPoint pt1 = new ReflectPoint(3,3);
- ReflectPoint pt2 = new ReflectPoint(5,5);
- ReflectPoint pt3 = new ReflectPoint(3,3);
- collections.add(pt1);
- collections.add(pt2);
- collections.add(pt3);
- collections.add(pt1);
- System.out.println(collections.size());
- }
- }
复制代码
运行结果报错,Exception in thread "main" java.io.FileNotFoundException: config.properties (系统找不到指定的文件。),怎么回事 ,我配置文件了 ,
|