public void fingerprintFiles(List<String> paths, Polynomial p) throws FileNotFoundException, IOException { final RabinFingerprintLong rabin = new RabinFingerprintLong(p); for (String path : paths) { File file = new File(path); if (file.exists()) { rabin.reset(); rabin.pushBytes(ByteStreams.toByteArray(new FileInputStream(file))); System.out.println( String.format("%X %s", rabin.getFingerprintLong(), file.getAbsolutePath())); System.out.flush(); } else { System.err.print(String.format("Could not find file %s", path)); System.err.flush(); } } }
/** Rapidly fingerprint an entire stream's contents. */ public long getFullFingerprint(InputStream is) throws IOException { final RabinFingerprintLong finger = newFingerprint(); finger.pushBytes(ByteStreams.toByteArray(is)); return finger.getFingerprintLong(); }
public void fingerprintStdin(Polynomial p) throws IOException { final RabinFingerprintLong rabin = new RabinFingerprintLong(p); rabin.pushBytes(ByteStreams.toByteArray(System.in)); System.out.println(String.format("%X", rabin.getFingerprintLong())); }