package com.io.ioDemo;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class BufferedInputStreamDemo {
public static void main(String[] args) {
BufferedInputStream bis =null;
try {
bis = new BufferedInputStream(new FileInputStream(new File("c:\\bis.txt")));
byte[] bt = new byte[1024];
int hasread = 0;
while((hasread = bis.read(bt))!=-1){
System.out.println(new String(bt,0,hasread));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
if(bis!=null){
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
IO流——缓冲流之BufferedInputStream
最新推荐文章于 2023-04-10 17:52:33 发布