优化文本文件内容解析的bug

This commit is contained in:
chenxudong 2025-02-17 14:43:23 +08:00
parent feb6fa89da
commit cf5a078473
1 changed files with 9 additions and 0 deletions

View File

@ -16,6 +16,15 @@ public class TextParse extends FileParse {
try { try {
FileUtil.writeFromStream(stream, fileTmpPath); FileUtil.writeFromStream(stream, fileTmpPath);
res = FileUtil.readString(fileTmpPath, Charset.defaultCharset()); res = FileUtil.readString(fileTmpPath, Charset.defaultCharset());
StringBuilder stringBuilder = new StringBuilder();
for (char c : res.toCharArray()) {
if (c <= 176 && c >= 32) {
stringBuilder.append(c);
} else {
stringBuilder.append(" ");
}
}
res = stringBuilder.toString();
} catch (Exception e) { } catch (Exception e) {
log.info("解析文件 {} 错误, 原因 {}", fileType, e.getMessage(), e); log.info("解析文件 {} 错误, 原因 {}", fileType, e.getMessage(), e);
} finally { } finally {