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

[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條評論
主站蜘蛛池模板: 日日摸夜夜爽久久综合 | 中文字幕久久精品 | 日本一本在线观看 | 18在线观看 | 色偷偷要色偷偷网站视频在线 | 成人网在线观看 | 久久国产欧美日韩精品免费 | 国产成人综合久久精品红 | 中文字幕第13亚洲另类 | 国产高清美女一级a毛片久久 | 欧美理论在线 | 亚洲精品欧洲精品 | 爱爱夜夜爽成人夜夜爽 | 亚洲黄色高清视频 | 国产五月天在线 | 人成xxxwww免费视频 | 亚洲精品一区二区综合 | 国产精品久久久亚洲动漫 | 欧美精品久久久亚洲 | 久久sese | 无遮挡一级毛片性视频不卡 | 国产亚洲一区在线 | 国产精品日本一区二区在线播放 | 国产精品揄拍一区二区久久 | 九九九热在线精品免费全部 | www.久久精品视频 | 久久天堂| 午夜精品久久影院蜜桃 | 99爱在线视频 | 国产亚洲精品福利片 | 伊人网色 | 偷偷狠狠的日日高清完整视频 | 欧美成人性视频在线黑白配 | 国产高清一区二区三区免费视频 | 波多野结衣中文一区二区免费 | 久久精品国产三级不卡 | 亚洲欧美日韩一区二区在线观看 | 牛牛影视午夜免费福利 | 亚洲性夜夜时 | 91色综合久久 | 免费又黄又爽视频 |