我有以下代码可从互联网上下载
URLConnection ucon = url.openConnection();
InputStream is = ucon.getInputStream();
BufferedInputStream inStream = new BufferedInputStream(is, 8192);//this is value one
FileOutputStream outStream = new FileOutputStream(new File(location));
byte[] buff = new byte[8192];//this is value two
int len;
while ((len = inStream.read(buff)) != -1) {
outStream.write(buff, 0, len);
}
我的问题是如果我更改缓冲区值会发生什么:值1和2 下载速度如何变化?他们应该是相同的价值吗?如果它们不相同,它们应该表示什么?
我已阅读以下帖子:
How do you determine the ideal buffer size when using FileInputStream?
但我真的不明白。有人可以为我解释吗