-1
private static void fileChunking() throws IOException {
InputStream is = null;
OutputStream os = null;
byte[] buffer;
int maxBufferSize = 102400;
int bytesRead, bytesAvailable, bufferSize;
int responsecode = 0;
String responsemessage = null;
bufferSize = Math.min(content.length, maxBufferSize);
buffer = new byte[bufferSize];
bytesRead = is.read(buffer, 0, bufferSize);
while (bytesRead > 0) {
os.write(buffer, 0, bufferSize);
bytesAvailable = is.available();
bufferSize = Math.min(bytesAvailable, maxBufferSize);
bytesRead = is.read(buffer, 0, bufferSize);
}
is.close();
os.flush();
responsecode = con.getResponseCode();
responsemessage = con.getResponseMessage();
System.out.print(responsemessage);
}
代碼在讀取時拋出異常'流已打開' bytesRead = is.read(buffer,0,bufferSize);流已經打開 - 例外
該代碼無法執行,因爲您從未將「is」設置爲非null。什麼是真正的代碼?注意你不需要那個'Math.min()'東西:'read()'已經有這樣的表現。 – EJP
該代碼無法編譯,因爲沒有聲明名稱爲「content」的變量。 –