class FileUtil {

    public static String getFileChecksum( final String fileAbsPath, ChecksumMethod checksumMethod )
    {

        if ( ( StringUtils.isBlank( fileAbsPath ) ) || ( checksumMethod == null ) )
        {
            return null;
        }

        File file = new File( fileAbsPath );
        if ( ( !file.exists() ) || ( !file.isFile() ) )
        {
            return null;
        }

        FileInputStream fis = null;
        BufferedInputStream bis = null;

        try
        {
            fis = new FileInputStream( file );
            bis = new BufferedInputStream( fis );
            if ( checksumMethod == ChecksumMethod.SHA1 )
            {
                return DigestUtils.sha1Hex( bis );
            }
            else if ( checksumMethod == ChecksumMethod.MD5 )
            {
                return DigestUtils.md5Hex( bis );
            }
            else if ( checksumMethod == ChecksumMethod.SHA256 )
            {
                return DigestUtils.sha256Hex( bis );
            }
        }
        catch ( FileNotFoundException e )
        {
            logger.error( "Error while computing checksum for the file - {} using algorithm - {}.", fileAbsPath,
                          checksumMethod.toString(), e );
        }
        catch ( IOException e )
        {
            logger.error( "Error while computing checksum for the file - {} using algorithm - {}.", fileAbsPath,
                          checksumMethod.toString(), e );
        }
        finally
        {
            try
            {
                if ( bis != null )
                {
                    bis.close();
                }
                if ( fis != null )
                {
                    fis.close();
                }
            }
            catch ( IOException e )
            {
            }
        }
        return null;
    }

    private  FileUtil();

}