当前位置: 动力学知识库 > 问答 > 编程问答 >

Excel File getting corrupt on ec2 linux java while downloading

问题描述:

I am trying to download an excel file from my application. Below is my code snippet:`

response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

response.setHeader("Content-Disposition", "attachment; filename=\""

+file + "\"");

if(inputStream==null){

logger.debug("The stream is null!!");

}

int stream;

while ((stream = inputStream.read()) != -1) {

out.write(stream);

}

inputStream.close();

out.close();

response.flushBuffer();

This works fine for windows (tomcat server), but when I run it on linux (weblogic server) the download excel file shows: "Data might be corrupted" warning. Though it opens up and shows the right content, I don't understand why this warning comes on linux. Is there a way I can remove this warning?

分享给朋友:
您可能感兴趣的文章:
随机阅读: