/*缓冲流:读取数据大量的文件时,读取的速度慢java提供了一套缓冲流 提高io流的效率
*
*/
package cn.lijun.demo; import java.io.BufferedInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
/*
* 字节输入流的缓冲流
* 继承InputStream
* 构造方法
*/
public class BufferedInputStreamDemo {
public static void main(String[] args) throws Exception {
//创建字节输入流的缓冲流对象
BufferedInputStream bis=new BufferedInputStream(new FileInputStream("d:\\b.txt"));
byte[] b=new byte[1024];
int len=0;
while((len=bis.read(b))!=-1){
System.out.println(new String(b,0,len));
}
bis.close();
} } package cn.lijun.demo; import java.io.BufferedOutputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
/*
* 字节输出流的缓冲流 作用 提高效率
* 继承OutputStream
* 构造方法new BufferedOutputStream(OutputStream out);
*/
public class BufferedOutputStreamDemo {
public static void main(String[] args) throws Exception {
FileOutputStream fos=new FileOutputStream("d:\\b.txt");
BufferedOutputStream bos=new BufferedOutputStream(fos); bos.write(65);
byte[] b="hello world".getBytes();
bos.write(b);
bos.write(b,3,2); //从索引为三的开始 截取两位数
bos.close();
} }

最新文章

  1. GridView中数据的汇总方法
  2. string转byte[]
  3. 简单实用的二级树形菜单hovertree
  4. 地图编辑器V3
  5. Construct Binary Tree from Preorder and Inorder Traversal
  6. How to Allow MySQL Client to Connect to Remote MySql
  7. [转]OBOUT ASP.NET HTML Editor - Insert HTML
  8. My_Python的常用函数.
  9. linux中deb怎样安装
  10. vs 设置生成的实体为复数
  11. C#设计模式学习资料--观察者模式
  12. Linux C/C++ 编程练手 --- 大数相加和大数相乘
  13. sys.stdout 重定向
  14. poj 1001 求高精度幂
  15. 转:js中cookie的使用详细分析
  16. HashMap方法介绍
  17. Android Studio打开项目,停在gradle的解决方案
  18. zuul的学习
  19. Week 1 工程表格
  20. Netty Reactor 线程模型笔记

热门文章

  1. 使用 Travis CI 自动部署 Hexo 站点至 GitHub Pages
  2. 【python练习题】程序10
  3. Django+Vue打造购物网站(三)
  4. Mining Station on the Sea HDU - 2448(费用流 || 最短路 && hc)
  5. HDOJ5551 Huatuo's Medicine
  6. 自学Python之路-Python核心编程
  7. [luogu4072][bzoj4518][SDOI2016]征途【动态规划+斜率优化】
  8. table用模板生成的问题
  9. Nginx+Tomcat-cluster构建
  10. webRequest封装