处理拆分钟linux系统和windows系统不兼容问题以及其他报错信息

This commit is contained in:
wangchengjun
2022-05-26 22:27:12 +08:00
parent 1f2e2a86fd
commit a5a667b1bc
2 changed files with 14 additions and 4 deletions
@@ -433,7 +433,17 @@ public class FileSpiltService {
if (StringUtils.isEmpty(readPdf)) {
throw new JeroBootException("未读取到文件内容,请检查后重试!");
}
String[] pdfArrays = readPdf.split("\r\n");
String[] pdfArrays;
String os = System.getProperty("os.name");
//Windows操作系统
if (os != null && os.toLowerCase().startsWith("windows")) {
pdfArrays = readPdf.split("\r\n");
} else if (os != null && os.toLowerCase().startsWith("linux")) {//Linux操作系统
pdfArrays = readPdf.split("\n");
} else { //其它操作系统
pdfArrays = readPdf.split("\n");
}
// Pattern ptest ;
// Matcher matcher;
@@ -487,7 +497,6 @@ public class FileSpiltService {
// ptest = Pattern.compile("^[\\d.]*$");
boolean hasGoIf = false;
for (int i = 0; i < nowStart.size(); i++) {
System.out.println(nowStart.get(i));
if (paragraphString.startsWith(nowStart.get(i))) {
// 判断名称,如果大于10位,取十位,
// String itemName = paragraphString.substring(nowStart.get(i).length()).length()>10?paragraphString.substring(nowStart.get(i).length(),nowStart.get(i).length()+10):paragraphString.substring(nowStart.get(i).length());
@@ -540,6 +549,7 @@ public class FileSpiltService {
}
} catch (JeroBootException e) {
e.printStackTrace();
throw new JeroBootException(e.getMessage());
} catch (Exception e) {
e.printStackTrace();