import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
public class IO字节流 {
//用字节流读取数据
public static void main(String[] args) {
File f = new File("a.txt");
InputStream is = null;
try {
is = new FileInputStream(f);
//分段读取
byte[] flush = new byte[1024]; //缓冲容器
int len; //接收长度
while((len = is.read(flush)) != -1) {
String s = new String(flush,0,len);
System.out.print(s);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
if(is != null)
is.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}