1,创建文件{File f = new File("hello.txt"); }1~,打开文件{FileOutputStream out = new FileOutputStream(f);}1~~,写文件{out.write(buf);}
2,文件关闭{out.close();}2~,打开文件{FileInputStream in = new FileInputStream(f);}2~~,读文件{byte [] buf = new byte[1024];int len = in.read(buf);}
2,文件关闭{out.close();}2~,打开文件{FileInputStream in = new FileInputStream(f);}2~~,读文件{byte [] buf = new byte[1024];int len = in.read(buf);}
{// 把指定文件中的数据读出来
FileInputStream in = new FileInputStream(f);
byte [] buf = new byte[1024]; // 请问哪句指令使文件中的数据读入 byte [] buf
int len = in.read(buf); // 将当前输入流中 b.length 个字节数据读到一个字节数组中
System.out.println(new String(buf,0,len));
}
catch(Exception e)
{
System.out.println(e.getMessage());
}
}