日期:2014-05-20  浏览次数:20779 次

请问是什么问题呢?
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写运行就有上面的问题,用命令去敲的时候就不行了?


------解决方案--------------------
探讨
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[]
……