//字节流输入输出
FileInputStream
//构造方法
1. FileInputStream fileInputStream = new FileInputStream(String)
2. FileInputStream fileInputStream = new FileInputStream(File)
//快速读取
3.{
byte[] buf = new byte[8];
int rl = 0;
while((rl = fileInputStream.read(buf)) != -1)
{
System.out.println(new String(buf,0,rl));
}
}
FileOutputStream
//不写默认false,true时输出为追加
1. FileOutputStream fileOutputStream = new FileOutputStream(String,boolean);
2. FileOutputStream fileOutputStream = new FileOutputStream(File , boolean);
//快速写出
//写入buf再写出
3.{
byte[] buf = new byte[8];
int rl = 0;
while((rl = fileInputStream.read(buf)) != -1)
{
fileOutputStream.write(buf,0,rl);
}
}
字节流FileInputStream和FileOutputStream
最新推荐文章于 2024-05-18 16:42:38 发布