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);
}