From e1112bd3e52018c55f6887cae552d9d342bc171a Mon Sep 17 00:00:00 2001 From: caihaohan Date: Wed, 9 Oct 2024 16:12:28 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=9C=A8=E7=BA=BF=E7=BC=96=E8=BE=91?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E5=8A=A0=E8=BD=BD=E6=96=B9=E5=BC=8F=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E6=89=8B=E5=8A=A8=E8=A7=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/ProcessFileServiceImpl.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/ProcessFileServiceImpl.java b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/ProcessFileServiceImpl.java index 9502edf1..21e002f5 100644 --- a/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/ProcessFileServiceImpl.java +++ b/laws-modules/src/main/java/com/jero/modules/onlyoffice/service/impl/ProcessFileServiceImpl.java @@ -22,8 +22,8 @@ import javax.annotation.Resource; import java.io.File; import java.io.FileInputStream; import java.net.URL; -import java.nio.file.Path; -import java.nio.file.Paths; +import java.net.URLDecoder; +import java.nio.charset.StandardCharsets; import java.util.Arrays; import java.util.Comparator; import java.util.List; @@ -57,10 +57,11 @@ public class ProcessFileServiceImpl implements IProcessFileService { try { URL fileUrl = getClass().getClassLoader().getResource("wordTemplate/DOCX.docx"); if (fileUrl != null) { - Path filePath = Paths.get(fileUrl.toURI()); - log.info("File path: " + filePath); + String decodedPath = URLDecoder.decode(fileUrl.getPath(), StandardCharsets.UTF_8.name()); + File file = new File(decodedPath); + System.out.println("File path: " + file.getAbsolutePath()); } else { - log.info("File not found!"); + System.err.println("File not found!"); } File file = new File(fileUrl.getFile()); FileInputStream fileInputStream = new FileInputStream(file);