为什么我的fileoutputstream的write方法不能直接传入byte的数组?
public void m() {
String path="D:\\hello.txt";
FileOutputStream fileOutputStream=null;
try {
fileOutputStream=new FileOutputStream(path);
//写入内容方式一:
//fileOutputStream.write('H');
//写入内容方式二:
String str="helloWorld";
Byte[] bytes = new Byte[str.length()];
for(int i=0;i<str.length();i++){
bytes[i]=(byte)(str.charAt(i));
}
for(int i=0;i<bytes.length;i++){
System.out.print(bytes[i]+" ");
}
fileOutputStream.write(bytes);
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
fileOutputStream.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
第十八行说我编译出错了