内部的缓冲byte[]buffer,定义的大小为4096,如果要写的io流内容超过这个大小呢贴个源码:publicstaticintcopy(InputStreaminput,OutputStreamoutput)throwsIOException{longcount=copyLarge(input,output);if(count>Integer.MAX_VALUE){return-1;}return(int)count;}publicstaticlongcopyLarge(InputStreaminput,OutputStreamoutput)throwsIOException{returncopyLarge(input,output,newbyte[DEFAULT_BUFFER_SIZE]);//大小为4096}publicstaticlongcopyLarge(InputStreaminput,OutputStreamoutput,byte[]buffer)throwsIOException{longcount=0;intn=0;while(EOF!=(n=input.read(buffer))){output.write(buffer,0,n);count+=n;}returncount;}也没看见对buffer有什么别的处理呀?如果buffer大小不够呢?
白衣染霜花
相关分类