From: Janus Varmarken Date: Fri, 27 Jul 2018 01:02:41 +0000 (-0700) Subject: TriggerTimesFileReader.java: use try-with such that trigger times file is properly... X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=d63d6ef6212b92848debffc676e7abb214063ec4;p=pingpong.git TriggerTimesFileReader.java: use try-with such that trigger times file is properly closed after use --- diff --git a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/io/TriggerTimesFileReader.java b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/io/TriggerTimesFileReader.java index b116909..75d06ec 100644 --- a/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/io/TriggerTimesFileReader.java +++ b/Code/Projects/SmartPlugDetector/src/main/java/edu/uci/iotproject/io/TriggerTimesFileReader.java @@ -32,9 +32,8 @@ public class TriggerTimesFileReader { */ public List readTriggerTimes(String fileName, boolean _24hFormat) { List listTriggerTimes = new ArrayList<>(); - try { - File file = new File(fileName); - BufferedReader br = new BufferedReader(new FileReader(file)); + File file = new File(fileName); + try (BufferedReader br = new BufferedReader(new FileReader(file))) { String s; while ((s = br.readLine()) != null) { listTriggerTimes.add(parseTriggerTimestamp(s, _24hFormat));