From 94c0159348da09527032440465d6a81b7b75fb25 Mon Sep 17 00:00:00 2001 From: ptaillandier Date: Fri, 3 Dec 2021 15:41:54 +0700 Subject: [PATCH] Fixes the save of the result in SoBol --- .../batch/exploration/SobolExploration.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/msi.gama.core/src/msi/gama/kernel/batch/exploration/SobolExploration.java b/msi.gama.core/src/msi/gama/kernel/batch/exploration/SobolExploration.java index 480f3297f8..57cf48de92 100644 --- a/msi.gama.core/src/msi/gama/kernel/batch/exploration/SobolExploration.java +++ b/msi.gama.core/src/msi/gama/kernel/batch/exploration/SobolExploration.java @@ -137,21 +137,21 @@ public void explore(final IScope scope) throws GamaRuntimeException { } computeSobolIndexes(scope); + if (hasFacet(IKeyword.BATCH_REPORT)) { String path_to = Cast.asString(scope, getFacet(IKeyword.BATCH_REPORT).value(scope)); - FileWriter fw; - try { - final File f = new File(FileUtils.constructAbsoluteFilePath(scope, path_to, false)); - final File parent = f.getParentFile(); - if (!parent.exists()) { parent.mkdirs(); } - if (f.exists()) f.delete(); - f.createNewFile(); - fw = new FileWriter(f, false); + final File f = new File(FileUtils.constructAbsoluteFilePath(scope, path_to, false)); + final File parent = f.getParentFile(); + if (!parent.exists()) { parent.mkdirs(); } + if (f.exists()) f.delete(); + + try (FileWriter fw = new FileWriter(f, false)) { fw.write(buildSobolReport()); + } catch (IOException e) { GamaRuntimeFileException.create(e, scope); - } + } } }