1. java读取文件时,InputStream的read(byte[])方法的byte[]的长度不知如何设置,请教大虾们
那个长度应该只是缓冲区而已,应该不影响结果的。我做的时候一般都设置为1024,即1KB
这个是我部分的成功代码
inputStream = new BufferedInputStream(new FileInputStream(
downloadFile));
outputStream = new BufferedOutputStream(response
.getOutputStream());
byte[] buffer = new byte[1024];
int readIndex;
while (-1 != (readIndex = inputStream.read(buffer, 0,
buffer.length))) {
outputStream.write(buffer, 0, readIndex);
}