BufferedOutputStream
文章目录
一、字节缓冲流
public class BufferedOutputStream
public class BufferedInputStream

缓冲流提高字节读取效率
构造函数
BufferedOutputStream(OutputStream out)
BufferedinputStream(inputStream in)
操作:
构造方法创建对象:
BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream("E:\\xx\\xx.txt"))读数据:
bos.write("hello\r\n".getBytes());资源释放:
bos.close();

构造方法创建对象:
BufferedInputStream bis = new BufferedInputStream(new FileInputStream(""E:\\xx\\xx.txt""));写数据:方法一 字符
int by; while((by=bis.read())!=-1){ System.Out.print(char(by)); }写数据:方法二 字节数组
Byte[] b = new Byte[1024]; int len; while((len=bis.read(b))!=-1){ System.out.Print(String(b,0,len)); }资源释放:
bis.close();

案例:复制视频

-----采用四种方式-----
基本字节流/字节缓冲流
--->对应
一次读一个字节/一次读一个字节数组

计时:
1
2
3
4
评论
登录后参与技术讨论,分享你的经验与见解。
登录 / 注册暂无评论