while (((len = fis2.read(buffer))>0)) bb.write(buffer, 0, len); 是什么意思,具体代码的意思
推荐于2017-10-05
展开全部
FileInputStream fis2 = new FileInputStream(filepath);
OutputStream bb= response.getOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while((len=fis2.read(buffer))>0){
bb.write(buffer,0,len);
}
fis2.read(buffer)将filepath的文件放郑清入buffer作为内存缓冲区并获得可读的长度len,
bb.write(buffer,0,len); 然后write(buffer,0,len)写到OutputStream中,每次都是从buffer内存处的0偏移开蠢轿始写,每次写带丛肆len字节
OutputStream bb= response.getOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while((len=fis2.read(buffer))>0){
bb.write(buffer,0,len);
}
fis2.read(buffer)将filepath的文件放郑清入buffer作为内存缓冲区并获得可读的长度len,
bb.write(buffer,0,len); 然后write(buffer,0,len)写到OutputStream中,每次都是从buffer内存处的0偏移开蠢轿始写,每次写带丛肆len字节
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询