解决pdf下载压缩包文件损坏bug

master
jian.wang 2 years ago
parent 6a3dade53b
commit 9338ef2496

@ -1344,6 +1344,8 @@ public class TemplateSearchController {
while ((len = bis.read(buf, 0, buf.length)) != -1) { while ((len = bis.read(buf, 0, buf.length)) != -1) {
bos.write(buf, 0, len); bos.write(buf, 0, len);
} }
bis.close(); // 及时关闭流,避免资源泄露
out.reset();
} }
} catch (Exception e) { } catch (Exception e) {
ExceptionPrintUtil.printException(e); ExceptionPrintUtil.printException(e);

@ -295,7 +295,7 @@ public class BatchExportServiceImpl implements BatchExportService {
public Boolean imageToPdf1(List<ExportDetailsVo> scanPathVos, ByteArrayOutputStream bos, EmrPdfWaterSet pdfWaterSet) { public Boolean imageToPdf1(List<ExportDetailsVo> scanPathVos, ByteArrayOutputStream bos, EmrPdfWaterSet pdfWaterSet) {
//ByteArrayOutputStream bos = null; //ByteArrayOutputStream bos = null;
FileOutputStream fileOutputStream = null; //FileOutputStream fileOutputStream = null;
PdfWriter writer = null; PdfWriter writer = null;
try { try {
//bos = new ByteArrayOutputStream(); //bos = new ByteArrayOutputStream();
@ -380,22 +380,20 @@ public class BatchExportServiceImpl implements BatchExportService {
e.printStackTrace(); e.printStackTrace();
return false; return false;
} finally { } finally {
//try { try {
if (writer != null) { if (writer != null) {
writer.close(); writer.close();
} }
/*if (fileOutputStream != null) { /*if (fileOutputStream != null) {
fileOutputStream.close(); fileOutputStream.close();
} }*/
if (bos != null) { if (bos != null) {
bos.flush(); bos.flush();
bos.close(); bos.close();
}*/ }
} catch (IOException e) {
/*} catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
}*/ }
} }
return true; return true;
} }

Loading…
Cancel
Save