feat:processFile

This commit is contained in:
nieziyan 2023-10-20 17:55:47 +08:00
parent 3c89a884af
commit 17d0844245

View File

@ -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<String, NuclideInfoData> m_mapNuclideInfo = processFile(new File(outFilePath));
File resultOutFile = new File(outFilePath);
Map<String, NuclideInfoData> 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<String, NuclideInfoData> processFile(File file){
Map<String, NuclideInfoData> 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();
}
}
// 排序