feat: 在线编辑文件加载方式改为手动解码

This commit is contained in:
2024-10-09 16:12:28 +08:00
parent 9ebe71d162
commit e1112bd3e5
@@ -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);