From 122cc84c8bd35c22de3490f0b9f4b9b7f2144638 Mon Sep 17 00:00:00 2001 From: zhangqinbin <181961702@qq.com> Date: Fri, 22 Apr 2022 17:34:43 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=98=E5=8E=9F=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ExpertSignatureServiceImpl.java | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/signature/service/impl/ExpertSignatureServiceImpl.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/signature/service/impl/ExpertSignatureServiceImpl.java index 18f1151..41829f5 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/signature/service/impl/ExpertSignatureServiceImpl.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/signature/service/impl/ExpertSignatureServiceImpl.java @@ -124,20 +124,16 @@ public class ExpertSignatureServiceImpl implements ExpertSignatureService { } File f = new File(path + "merged.pdf"); - FileOutputStream fos = null; - try { - FontSettings.getDefaultInstance().setFontsFolder(fontAddress, true); - fos = new FileOutputStream(f); + + FontSettings.getDefaultInstance().setFontsFolder(fontAddress, true); + try (FileOutputStream fos = new FileOutputStream(f);) { com.aspose.words.Document doc = new com.aspose.words.Document(path + "merged.docx"); doc.save(fos, SaveFormat.PDF); - fos.flush(); } catch (Exception e) { log.info(ExceptionUtil.stacktraceToString(e)); } finally { - IOUtils.closeQuietly(source); - IOUtils.closeQuietly(addObj); - IOUtils.closeQuietly(fos); - + source.close(); + addObj.close(); } long l1 = System.currentTimeMillis();