File f = new File("new.txt");
  try{
   FileOutputStream fos = new FileOutputStream(f); //输出流
   Byte[] bu = "www.baidu.com".getBytes();     //Type mismatch: cannot convert from byte[] to Byte[] 
   fos.write(bu);    //The method write(int) in the type FileOutputStream is not applicable for the arguments (Byte[])
   fos.close();
  }catch(Exception e){
   e.printStackTrace();
  }
  
  try{
   FileInputStream fis = new FileInputStream(f); //输入流.
   Byte[] buf = new Byte[1024];
   int len = fis.read();
   System.out.println(new String(buf,0,len));   //The constructor String(Byte[], int, int) is undefined
  }catch(Exception e){
   e.printStackTrace();
  }问题补充: 为什么我用eclipse写运行就有上面的问题,用命令去敲的时候就不行了?

解决方案 »

  1.   

    代码没问题,应该是路径引起的,File f = new File("new.txt");试试全路径...
      

  2.   


    Byte -> byte  前一个是封装类,后一个是基本对象
    "www.baidu.com".getBytes(); 返回的是基本对象的
    new String(buf,0,len) :需要的也是基本对象的
      

  3.   

    如果代码相同,那只能是javac的版本不同!