从test.txt文件内容读取出来
public class BuferedDemo {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
BufferedInputStream bi=null;
try {
bi=new BufferedInputStream(new FileInputStream("F:\\test.txt"));
int result=0;
byte[] by=new byte[1024];
System.out.print("文件内容的结构如下:");
while ((result=bi.read(by))>0) {
System.out.print(new String(by, 0, result));
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}
finally{
try {
bi.close();
} catch (IOException e2) {
// TODO: handle exception
e2.printStackTrace();
}
}
}
}
BufferedOutputStream和上面类似