InputStream is = new FileInputStream(filePath);
byte[] b = new byte[8 * 1024]; int length = -1; OutputStream out = response.getOutputStream(); while ((length = is.read(b)) != -1) { out.write(b, 0, length); } out.close(); is.close();
1:里面为什么length=-1 等于其他不行么? 2:可以这样写吗: int length=is.read(b); while(length!=-1){ .............................. }
繁星淼淼
相关分类