黑马程序员技术交流社区

标题: 不能将FileInputSrteam类型的对象传入到参数类型为InputStream的... [打印本页]

作者: 齐宁宁    时间: 2014-10-15 20:16
标题: 不能将FileInputSrteam类型的对象传入到参数类型为InputStream的...

public class MyEncoderText {
        public static void main(String[] args)throws Exception {
                String path0=args[0];
                String path1=args[1];
                FileInputStream in=new FileInputStream(path0);
                FileOutputStream out=new FileOutputStream(path1);
                 cypher(in,out);       //为什么在这里会出错,The method cypher(InputStream, OutputStream) in the type MyEncoderText is not applicable                                                 //for the arguments (FileInputStream, FileOutputStream)
                 System.out.println("结束");
                out.close();           
        }
        private static void cypher(InputStream inp,OutputStream oup)throws Exception{
                int len=-1;
                System.out.println("0:  "+len);               
                        while ((len=inp.read())!= -1){
                                System.out.println("1: "+len);
                                oup.write(len^102^91);
                                System.out.println("2: "+len);
                        }
                        System.out.println("3: "+oup);               
        }
}
为什么运行会出错?The method cypher(InputStream, OutputStream) in the type MyEncoderText is not applicable for the arguments (FileInputStream, FileOutputStream)
不能将FileInputSrteam类型的对象传入到参数类型为InputStream的方法中吗?

作者: 苏乞儿    时间: 2014-10-16 01:17
我运行了一下,没有出现你说的错误。。。。。
作者: 齐宁宁    时间: 2014-10-16 21:31
苏乞儿 发表于 2014-10-16 01:17
我运行了一下,没有出现你说的错误。。。。。

别人也这么说,但是我的连编译器都过不了,只要把方法中的参数类型换下就行。不知道怎么回事:(
作者: 齐宁宁    时间: 2014-10-17 11:58
发现错误了,是自己导包导错了,用的不是IO类中的包,现在一切都ok啦:lol




欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2