From 09c8cd8ce63f58d7d531d227370f0c926aed718c Mon Sep 17 00:00:00 2001 From: zhangqinbin <181961702@qq.com> Date: Thu, 21 Dec 2023 17:36:28 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=BF=E4=BC=81WPS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../extend/wps/controller/WpsController.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java index 08fa78e..7bc9b0c 100644 --- a/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java +++ b/src/main/java/com/chinaunicom/mall/ebtp/extend/wps/controller/WpsController.java @@ -293,15 +293,15 @@ public class WpsController { String fileName = fileIdName; String text = " "; byte buf[] = text.getBytes(); -// try { -//// URL crt = test.class.getClassLoader().getResource("text.doc"); -//// File file = new File(crt.getPath()); -//// BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file)); -//// buf = IOUtils.toByteArray(bis); -// }catch (Exception e){ -// log.error("读取异常",e); -// CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("模板文件读取异常",true); -// } + try { + File tempFile = File.createTempFile("tempDoc", ".doc"); + BufferedInputStream bis = new BufferedInputStream(new FileInputStream(tempFile)); + buf = IOUtils.toByteArray(bis); + tempFile.deleteOnExit(); + }catch (Exception e){ + log.error("读取异常",e); + CommonExceptionEnum.FRAME_EXCEPTION_COMMON_DATA_OTHER_ERROR.customValidName("模板文件读取异常",true); + } String fileLength = String.valueOf(buf.length);