赞
踩
字节缓冲输入流
与BufferedinputStream相似
public static void main(String[] args) throws IOException { //1:创建字节缓冲输入流 (包装流,底层包装的是字节缓冲流) BufferedInputStream bis = new BufferedInputStream(new FileInputStream("c.txt")); //2:读取数据 //2.1 一次读取一个字节 /* int read = bis.read(); System.out.println((char)read);*/ /*int num = 0; while((num = bis.read())!=-1){ System.out.print((char)num); }*/ //2.2 一次读取一个字节数组 int num = 0; byte[] by = new byte[1024]; while((num = bis.read(by))!=-1){ System.out.print(new String(by,0,num)); } //3:关闭流 bis.close(); }
赞
踩
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。