FileDocCategorySizeDatePackage
URLDigest.javaAPI DocExample698Mon Feb 13 11:57:50 GMT 2006None

URLDigest

public class URLDigest extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)


    URL u = new URL(args[0]);
    InputStream in = u.openStream();
    MessageDigest sha = MessageDigest.getInstance("SHA");
    byte[] data = new byte[128];
    while (true) {
      int bytesRead = in.read(data);
      if (bytesRead < 0) break;
      sha.update(data, 0, bytesRead);
    }
    byte[] result = sha.digest();
    for (int i = 0; i < result.length; i++) {
      System.out.print(result[i] + " ");
    }
    System.out.println();
    System.out.println(new BigInteger(result));