MD5 hash calculation error in java
<p>I'm using the below java code to calculate the md5 hash sums of a file input as argument. However, the code doesn't seem to be working, as this is always returning a false value.</p>

<pre><code>private static Boolean checkmd5sum(String file,String checksum) throws NoSuchAlgorithmException, IOException
{
    //byte[] bytes=System.IO.File.ReadAllBytes(file);

    //File f=new File(file);
    FileInputStream fis=new FileInputStream(file);
    byte[] bytes=new byte[(int)(new File(file).length())];
    fis.read(bytes);

    byte[] bsum=MessageDigest.getInstance("MD5").digest(bytes);
    String csum="";
    for (int i=0;i&lt;bsum.length ; i++)
    {
         String hex=Integer.toHexString(bsum[i]);
         if (hex.length()==1)
         {
             csum+="0"; 
         }
        //System.out.println("hex: " + hex);
         csum+=hex;
    }

    return (csum.equals(checksum));
}
</code></pre>
