From 8f867fc9e4c4f2bc3335c3526dc5887078533892 Mon Sep 17 00:00:00 2001 From: JEECG <445654970@qq.com> Date: Mon, 9 Mar 2026 21:00:52 +0800 Subject: [PATCH] =?UTF-8?q?issues/9402=20=E8=A7=A3=E5=86=B3=E6=96=87?= =?UTF-8?q?=E6=A1=A3=E5=90=91=E9=87=8F=E5=8C=96=EF=BC=8C=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=90=8D=E4=B8=AD=E6=96=87=E4=B9=B1=E7=A0=81=E5=AF=BC=E8=87=B4?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/airag/llm/document/TikaDocumentParser.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/llm/document/TikaDocumentParser.java b/jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/llm/document/TikaDocumentParser.java index 7e6fe3d2f..72b7c4d64 100644 --- a/jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/llm/document/TikaDocumentParser.java +++ b/jeecg-boot/jeecg-boot-module/jeecg-boot-module-airag/src/main/java/org/jeecg/modules/airag/llm/document/TikaDocumentParser.java @@ -30,7 +30,6 @@ import org.jeecg.common.util.AssertUtils; import org.xml.sax.ContentHandler; import java.io.*; -import java.nio.file.Files; import java.util.Arrays; import java.util.HashSet; import java.util.List; @@ -73,8 +72,8 @@ public class TikaDocumentParser { public Document parse(File file) { AssertUtils.assertNotEmpty("请选择文件", file); try { - // 用于解析 - InputStream isForParsing = Files.newInputStream(file.toPath()); + // 用于解析(使用FileInputStream避免file.toPath()在Linux非UTF-8环境下中文文件名报错) + InputStream isForParsing = new FileInputStream(file); // 使用 Tika 自动检测 MIME 类型 String fileName = file.getName().toLowerCase(); //后缀 @@ -102,7 +101,7 @@ public class TikaDocumentParser { */ public Document parseDocExcelPdfUsingApachePoi(File file) { AssertUtils.assertNotEmpty("请选择文件", file); - try (InputStream inputStream = Files.newInputStream(file.toPath())) { + try (InputStream inputStream = new FileInputStream(file)) { ApachePoiDocumentParser parser = new ApachePoiDocumentParser(); Document document = parser.parse(inputStream); if (document == null || Utils.isNullOrBlank(document.text())) {