Skip to content

Commit a30c0d6

Browse files
committed
try with resources
1 parent a3775b7 commit a30c0d6

File tree

1 file changed

+5
-5
lines changed
  • crypto-java/src/main/java/de/dominikschadow/javasecurity/symmetric

1 file changed

+5
-5
lines changed

crypto-java/src/main/java/de/dominikschadow/javasecurity/symmetric/AES.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ private void encrypt() {
8181

8282
private KeyStore loadKeystore(String keystorePath, char[] keystorePassword) throws KeyStoreException,
8383
CertificateException, NoSuchAlgorithmException, IOException {
84-
InputStream keystoreStream = getClass().getResourceAsStream(keystorePath);
84+
try (InputStream keystoreStream = getClass().getResourceAsStream(keystorePath)) {
85+
KeyStore ks = KeyStore.getInstance("JCEKS");
86+
ks.load(keystoreStream, keystorePassword);
8587

86-
KeyStore ks = KeyStore.getInstance("JCEKS");
87-
ks.load(keystoreStream, keystorePassword);
88-
89-
return ks;
88+
return ks;
89+
}
9090
}
9191

9292
private static Key loadKey(KeyStore ks, String keyAlias, char[] keyPassword) throws KeyStoreException,

0 commit comments

Comments
 (0)