标签:output content nal byte finally except xlsx string 初始化
String fileName="test";
ClassPathResource classPathResource = new ClassPathResource("template/eventAndProperty.xlsx");
// 判断下载哪个excel
// 初始化流
InputStream inputStream = null;
OutputStream outputStream = null;
try {
inputStream = classPathResource.getInputStream();
response.setContentType("application/x-msdownload");
outputStream = response.getOutputStream();
response.addHeader("Content-Disposition", "attachment; filename=" + new String(fileName.getBytes(),"iso-8859-1"));
// 执行流操作
IoUtils.copy(inputStream,outputStream);
} catch (IOException e) {
log.error(e.getMessage());
}finally {
// 关流
IOUtils.closeQuietly(inputStream);
IOUtils.closeQuietly(outputStream);
}
标签:output content nal byte finally except xlsx string 初始化
原文地址:https://www.cnblogs.com/bt2882/p/13176665.html