try {
fin = new BufferedInputStream(new FileInputStream(source));
fout = new BufferedOutputStream(new FileOutputStream(target));
byte[] buffer = new byte[1024];
int result;
while ((result = fin.read(buffer)) != -1){
fout.write(buffer,0,result);
}
老师您好,请教一个问题, BufferedInputStream这个具体装饰类并没有去重写InputStream的read(byte[])byte方法,所以您调用的这个方法其实还是FileInputStream这个被装饰者实现的,BufferedInputStream并没有起到装饰器的作用,但是BufferedInputStream重写了read(byte b[], int off, int len)这个方法,您是否应该这样写来利用到BufferedInputStream的优势。
while ((result = fin.read(buffer,0,buffer.length)) != -1)