黑马程序员技术交流社区

标题: 这应该是多态啊,为什么错呢? [打印本页]

作者: 谢波    时间: 2013-2-7 21:41
标题: 这应该是多态啊,为什么错呢?
  1. package mypackage;

  2. import java.io.File;
  3. import java.io.FileInputStream;
  4. import java.io.FileOutputStream;
  5. import java.io.InputStream;

  6. import org.omg.CORBA_2_3.portable.OutputStream;

  7. public class ClassLoaderTest {

  8.         /**
  9.          * @param args
  10.          */
  11.         public static void main(String[] args) throws Exception{
  12.                 File srcFile = new File(args[0]);
  13.                 File destDir = new File(args[1]);
  14.                
  15.                 FileInputStream fis = new FileInputStream(srcFile);
  16.                 File destFile = new File(destDir,srcFile.getName());
  17.                 FileOutputStream fos = new FileOutputStream(destFile);

  18.                 cypher(fis,fos);//编译不能通过,为什么呢?不是多态吗?求解
  19.         }
  20.         private static void cypher(InputStream is,OutputStream os)throws Exception
  21.         {
  22.                 int b = -1;
  23.                 while((b=is.read())!=-1)
  24.                         os.write(b ^ 0xff);   
  25.                 is.close();
  26.                 os.close();
  27.         }

  28. }
复制代码

作者: 朱玉玺    时间: 2013-2-7 21:59
兄弟,OutputStream你的包导错了 import org.omg.CORBA_2_3.portable.OutputStream; 应该导入java.io.OutputStream.
作者: 谢波    时间: 2013-2-7 22:11
{:soso_e127:}谢谢了
晕死
看来 真是老了  

作者: 胡发友    时间: 2013-2-7 22:38
同学,File类有构造函数可以接受数组的?




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