请问各位高手:我想从一个BufferedInputStream类型的(receiver)流中成块的读取数据,并且把读取的数据写进一个数组中去,有什么比较好的解决方法啊?我希望将整个receiver流中的全部写进数组中,并且能够正常结束。希望各位大虾多多指教。

解决方案 »

  1.   

    read(byte[] b, int off, int len)
      

  2.   

    我的目的主要是想提高BufferedInputStream类型的(receiver)流的读取速度!我试过了二楼的方法,好象速度并没有提高!
    代码片段如下所示:
            byte[] a=new byte[1024];
            while((receiver.read(a,0,1024)!= -1)){
             if((count+1024)>=data.length){
             data=addCapacity(data);
             }
             System.arraycopy(a,0,data,count,a.length);
             count=count+1024;
            }
    其中data是一个动态数组,可以增加容量(addCapacity(data)),receiver是一个BufferedInputStream类型的流。流比较大,希望有更快的方法能够将流中的内容存到data数组中