Browse Source

update server/src/main/java/cn/keking/service/FileHandlerService.java.
修复xlsx7.4以上版本 乱码

Signed-off-by: 高雄 <admin@cxcp.com>

高雄 2 years ago
parent
commit
94503ddc39
1 changed files with 2 additions and 3 deletions
  1. 2 3
      server/src/main/java/cn/keking/service/FileHandlerService.java

+ 2 - 3
server/src/main/java/cn/keking/service/FileHandlerService.java

@@ -41,8 +41,6 @@ import java.util.Map;
 public class FileHandlerService {
 
     private final Logger logger = LoggerFactory.getLogger(FileHandlerService.class);
-
-    private static final String DEFAULT_CONVERTER_CHARSET = System.getProperty("sun.jnu.encoding");
     private final String fileDir = ConfigConstants.getFileDir();
     private final CacheService cacheService;
 
@@ -142,9 +140,10 @@ public class FileHandlerService {
      * @param outFilePath 文件绝对路径
      */
     public void doActionConvertedFile(String outFilePath) {
+         String charset = EncodingDetects.getJavaEncode(outFilePath);
         StringBuilder sb = new StringBuilder();
         try (InputStream inputStream = new FileInputStream(outFilePath);
-             BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, DEFAULT_CONVERTER_CHARSET))) {
+             BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, charset))) {
             String line;
             while (null != (line = reader.readLine())) {
                 if (line.contains("charset=gb2312")) {