java代码i/o流类
总结:BufferedInputStream();
package com.aini; import java.io.*; //使用BufferedInputStream读取文件 public class yhtrds { //这是一个方法 public static byte[] readFileByBufferedInputStream(File file){ BufferedInputStream bis; FileInputStream fis; ByteArrayOutputStream ot=new ByteArrayOutputStream();//字节数组输出流 try{//代码块,正常的。 fis=new FileInputStream(file); bis=new BufferedInputStream(fis); byte []b=new byte[1023]; int length; while((length=bis.read(b,0,b.length))!=-1){ ot.write(b,0,length); } }catch(Exception e){ System.out.println("Error occurs during reading:"+file.getAbsoluteFile()); }finally{ if(fis!=null) fis.close(); if(bis!=null) bis.close(); if(ot!=null) ot.close();//这里有错误,威慑么 } return ot.toByteArray(); } public static void main(String[] args) { } }