FileDocCategorySizeDatePackage
InstanceCallbackDigest.javaAPI DocExample853Sun Dec 12 10:51:22 GMT 2004None

InstanceCallbackDigest

public class InstanceCallbackDigest extends Object implements Runnable

Fields Summary
private File
input
private InstanceCallbackDigestUserInterface
callback
Constructors Summary
public InstanceCallbackDigest(File input, InstanceCallbackDigestUserInterface callback)

    this.input = input;
    this.callback = callback;
  
Methods Summary
public voidrun()


    try {
      FileInputStream in = new FileInputStream(input);
      MessageDigest sha = MessageDigest.getInstance("SHA");
      DigestInputStream din = new DigestInputStream(in, sha);
      int b;
      while ((b = din.read()) != -1) ;
      din.close();
      byte[] digest = sha.digest();
      callback.receiveDigest(digest);
    }
    catch (IOException ex) {
      System.err.println(ex);
    }
    catch (NoSuchAlgorithmException ex) {
      System.err.println(ex);
    }