diff --git a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java index 93c3d2ea..2b4b197c 100644 --- a/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java +++ b/jeecg-module-spectrum-analysis/src/main/java/org/jeecg/modules/service/impl/GammaServiceImpl.java @@ -2248,12 +2248,17 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi pb.directory(new File(parameterProperties.getFilePath())); try { pb.start(); + Thread.sleep(300); } catch (IOException e) { - throw new RuntimeException(e); + e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); } //读取生成的结果文件 并将数据存入对应的map中 String outFilePath = parameterProperties.getFilePath() + File.separator + "result.out"; - Map m_mapNuclideInfo = processFile(new File(outFilePath)); + File resultOutFile = new File(outFilePath); + Map m_mapNuclideInfo = processFile(resultOutFile); + resultOutFile.delete(); result.setSuccess(true); result.setResult(m_mapNuclideInfo); return result; @@ -2262,7 +2267,11 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi private Map processFile(File file){ Map m_mapNuclideInfo = new TreeMap<>(); if (ObjectUtil.isNull(file)) return m_mapNuclideInfo; - try (BufferedReader reader = new BufferedReader(new FileReader(file))) { + FileReader fileReader = null; + BufferedReader reader = null; + try{ + fileReader = new FileReader(file); + reader = new BufferedReader(fileReader); String nucline_flag = "-----------------------------------------"; String energy_flag = "REL. IMPULSANZ. KORR.FAKTOR"; String line = reader.readLine(); @@ -2304,6 +2313,13 @@ public class GammaServiceImpl extends AbstractLogOrReport implements IGammaServi } } catch (IOException e) { e.printStackTrace(); + }finally { + try { + if (ObjectUtil.isNotNull(fileReader)) fileReader.close(); + if (ObjectUtil.isNotNull(reader)) reader.close(); + } catch (IOException e) { + e.printStackTrace(); + } } // 排序