优化文本文件内容解析的bug
This commit is contained in:
parent
feb6fa89da
commit
cf5a078473
|
|
@ -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 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue