Some updates and code improvements (#1288)

* try with resources

* StringBuilder

* removed ant and updated spring boot
This commit is contained in:
René Zubcevic
2022-07-10 17:13:26 +02:00
committed by GitHub
parent 7dd0dd0923
commit e4eb5d783a
17 changed files with 46 additions and 62 deletions

View File

@@ -164,9 +164,10 @@ public class MD5 {
* @since ostermillerutils 1.00.00
*/
public static byte[] getHash(File f) throws IOException {
InputStream is = new FileInputStream(f);
byte[] hash = getHash(is);
is.close();
byte[] hash = null;
try (InputStream is = new FileInputStream(f)) {
hash = getHash(is);
}
return hash;
}
@@ -179,9 +180,10 @@ public class MD5 {
* @since ostermillerutils 1.00.00
*/
public static String getHashString(File f) throws IOException {
InputStream is = new FileInputStream(f);
String hash = getHashString(is);
is.close();
String hash = null;
try (InputStream is = new FileInputStream(f)) {
hash = getHashString(is);
}
return hash;
}
@@ -515,7 +517,7 @@ public class MD5 {
* @since ostermillerutils 1.00.00
*/
private static String toHex(byte hash[]) {
StringBuffer buf = new StringBuffer(hash.length * 2);
StringBuilder buf = new StringBuilder(hash.length * 2);
for (byte element : hash) {
int intVal = element & 0xff;
if (intVal < 0x10) {