亚洲免费在线-亚洲免费在线播放-亚洲免费在线观看-亚洲免费在线观看视频-亚洲免费在线看-亚洲免费在线视频

[FW:] Writing big files to ServletOutputStre

系統 1771 0

Problem when writing big files to ServletOutputStream

I am using the following code to write files to servlet output stream. The problem is the browser is not downloading the entire file when the file size grows above 10 MB. Any help would be greatly helpful.

FileInputStream fis = new FileInputStream(new File(fileName));
response.setHeader("Content-Disposition:", "attachment;filename=" + fileName );
BufferedInputStream bis= new BufferedInputStream(fis);
ServletOutputStream sos = response.getOutputStream();
byte[] buffer = new byte[5000];
response.setHeader("Content-Length:", String.valueOf (bis.available()));
while (true) {
int bytesRead = bis.read(buffer, 0, buffer.length);
if (bytesRead < 0)
break;
sos.write(buffer, 0, bytesRead);
}
fis.close();
sos.flush();
sos.close();

<!-- <form class="userinput"> <div class="center"><button type="submit" onmouseover="this.className='over'" onmouseout="this.className='';" onmousedown="this.className='down'">Post reply</button></div> </form> -->
<!-- header -->
<!-- info --> Message #141567 <!-- button --> Mark as noisy Mark as noisy Mark as noisy <!-- button --> Post reply Post reply Post reply <!-- button --> Go to top Go to top Go to top

Problem when writing big files to ServletOutputStream

Posted By: Krishnan Muthusubramanian on October 06, 2004 @ 11:45 AM in response to Message #141542 0 replies in this thread
response.setHeader("Content-Length:", String.valueOf (bis.available()));
The 'available' method of InputStream does not return the number of bytes that avilable :). Check the Java Doc for this method.

Try new File(fileName).length() instead

[FW:] Writing big files to ServletOutputStream


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 亚洲精品亚洲人成毛片不卡 | 亚洲91色 | 精品久久久久久国产91 | 国产一级毛片国语普通话对白 | 免费一级毛片无毒不卡 | 最新日韩在线 | 亚洲欧美日韩国产精品网 | 天海翼一区二区三区高清视频 | 国产福利视频精品 | 精品哟哟哟国产在线观看不卡 | 中文字幕在线观看一区二区三区 | 国产精品香蕉在线一区二区 | 成 人 黄 色 视频 免费观看 | 9191精品国产费久久 | 亚洲精品亚洲人成人网 | 一区二区三区成人 | 久久中文字幕日韩精品 | 午夜香蕉成视频人网站高清版 | 欧美精品午夜毛片免费看 | 奇米影视7777777 | 天天操人人| 成年女人免费视频 | 亚洲精品久久久中文字 | 国产xxx视频| 女人18免费毛片视频 | 久久精品一区二区三区中文字幕 | 成年女人毛片免费播放人 | 九九免费精品视频在这里 | 中文字幕不卡一区2021 | 乱人伦中文字幕在线看 | 亚洲精品久久久 | 免费看一级黄色录像 | 中文字幕在线观看亚洲 | 成人精品视频 成人影院 | 色综合狠狠操 | 久久噜噜噜| 一区二三区国产 | 91国内精品久久久久免费影院 | 国产精品免费视频一区二区三区 | 欧美午夜毛片a级在线 | 欧美日韩中文国产一区二区三区 |