From c5dd705defa2e0307b275171c38feb917fc73aa3 Mon Sep 17 00:00:00 2001 From: Chakradhar Bandla Date: Thu, 27 Aug 2020 15:25:52 +0100 Subject: [PATCH] close file after checksum calculation --- src/main/java/uk/ac/ebi/pride/gui/util/Hash.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/uk/ac/ebi/pride/gui/util/Hash.java b/src/main/java/uk/ac/ebi/pride/gui/util/Hash.java index 0acf1ac6..14e7daea 100644 --- a/src/main/java/uk/ac/ebi/pride/gui/util/Hash.java +++ b/src/main/java/uk/ac/ebi/pride/gui/util/Hash.java @@ -13,7 +13,12 @@ public class Hash { private final static Logger LOGGER = LoggerFactory.getLogger(Hash.class); public static String getSha1Checksum(File file) throws IOException { - return DigestUtils.sha1Hex(new FileInputStream(file)); + + FileInputStream fileInputStream = new FileInputStream(file); + String checksum = DigestUtils.sha1Hex(fileInputStream); + fileInputStream.close(); + + return checksum; } public static String getSha256Checksum(String str) {