From 7e905380f84c05d5bf147d251a2fe1032e7f579a Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Sat, 19 May 2018 00:26:47 +0200 Subject: [PATCH] Added check before append review stats file. --- .../april/hebdobot/model/stats/ReviewDatasFile.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/org/april/hebdobot/model/stats/ReviewDatasFile.java b/src/org/april/hebdobot/model/stats/ReviewDatasFile.java index 263a0da..8c20df1 100644 --- a/src/org/april/hebdobot/model/stats/ReviewDatasFile.java +++ b/src/org/april/hebdobot/model/stats/ReviewDatasFile.java @@ -65,12 +65,15 @@ public class ReviewDatasFile { try { - String line = String.format("%s\t%d\t%d", stat.getDate().format(DateTimeFormatter.ofPattern("yyyyMMdd-hh'h'mm")), stat.getUserCount(), - stat.getDuration()); + if ((file != null) && (file.exists())) + { + String line = String.format("%s\t%d\t%d", stat.getDate().format(DateTimeFormatter.ofPattern("yyyyMMdd-hh'h'mm")), stat.getUserCount(), + stat.getDuration()); - StringList lines = StringsUtils.load(file); - lines.add(line); - StringsUtils.save(file, lines); + StringList lines = StringsUtils.load(file); + lines.add(line); + StringsUtils.save(file, lines); + } } catch (FileNotFoundException exception) {