我已經使用java代碼從服務器下載文件,並且在下載文件後,文件從服務器中刪除。文件的總大小是200GB。下載開始並顯示下載成功。當我檢查下載的文件大小隻有3.3 GB。並且該文件也不會被刪除。我檢查了錯誤日誌,但沒有日誌。這是我的代碼。3gb後下載失敗
byte b[] = new byte[2048];
int len = 0;
filein = new BufferedInputStream(new FileInputStream(file));
output = new BufferedOutputStream(response.getOutputStream());
response.setContentType("application/force-download");
response.setHeader("content-Disposition", "attachment; filename=" + fname); // downloaded file name
response.setHeader("content-Transfer-Encoding", "binary");
while ((len = filein.read(b)) > 0) {
output.write(b, 0, len);
output.flush();
}
output.close();
filein.close();
file.delete(); // delete file
請建議我缺少的是什麼..
你一定是在開玩笑。 200千兆字節?我不知道可以讓您每月下載超過150 GB的互聯網服務。 – tbodt
我似乎是一個壞主意,刪除文件,而不檢查下載是否成功。 – Dahaka
@Dahaka根據代碼,文件應該在成功下載後被刪除,但不會被刪除。 – anonymous