- package cn.itcast.day1;
- import java.io.*;
- import java.util.ArrayList;
- import java.util.Collection;
- import java.util.HashSet;
- import java.util.Properties;
- import org.omg.CORBA.portable.InputStream;
- public class ReflectAndConllection {
- public static void main(String[] args)throws Exception{
-
- //FileReader in= new FileReader("demo.properties");
-
-
- FileInputStream in = (FileInputStream) ReflectAndConllection.class.getClassLoader().getSystemResourceAsStream("cn/itcast/day1");
- Properties prop= new Properties();
- prop.load(in);
- in.close();
- String className= prop.getProperty("className");
- Collection conllections=(Collection)Class.forName(className).newInstance();
-
- //Collection conllections= new HashSet();
- Demo d1= new Demo(2,3);
- Demo d2= new Demo(2,3);
- Demo d3= new Demo(2,6);
- conllections.add(d1);
- conllections.add(d1);
- conllections.add(d2);
- conllections.add(d3);
- //System.out.println("d1"+d1+"...."+"d2"+d2);
- System.out.println(conllections.size());
- }
- }
复制代码
Exception in thread "main" java.lang.ClassCastException: java.io.ByteArrayInputStream cannot be cast to java.io.FileInputStream
at cn.itcast.day1.ReflectAndConllection.main(ReflectAndConllection.java:17)
总是会有这个异常抛出 哪里出问题了 高手指教一下
谢谢 |
|