public static List < Hash > calculateHashes ( File file ) throws IOException { if ( file == null || ! file . exists ( ) || ! file . canRead ( ) ) { return null ; } final List < Hash > hashes = new ArrayList <> ( ) ; try ( InputStream fis = Files . newInputStream ( file . toPath ( ) ) ) { hashes . add ( new Hash ( Hash . Algorithm . MD5 , DigestUtils . md5Hex ( fis ) ) ) ; } try ( InputStream fis = Files . newInputStream ( file . toPath ( ) ) ) { hashes . add ( new Hash ( Hash . Algorithm . SHA1 , DigestUtils . sha1Hex ( fis ) ) ) ; } try ( InputStream fis = Files . newInputStream ( file . toPath ( ) ) ) { hashes . add ( new Hash ( Hash . Algorithm . SHA_256 , DigestUtils . sha256Hex ( fis ) ) ) ; } try ( InputStream fis = Files . newInputStream ( file . toPath ( ) ) ) { hashes . add ( new Hash ( Hash . Algorithm . SHA_384 , DigestUtils . sha384Hex ( fis ) ) ) ; } try ( InputStream fis = Files . newInputStream ( file . toPath ( ) ) ) { hashes . add ( new Hash ( Hash . Algorithm . SHA_512 , DigestUtils . sha512Hex ( fis ) ) ) ; } return hashes ; }
Calculates the hashes of the specified file .