private static long getCRC ( InputStream is ) throws IOException { CheckedInputStream check = new CheckedInputStream ( is , new CRC32 ( ) ) ; BufferedInputStream in = new BufferedInputStream ( check ) ; while ( in . read ( ) != - 1 ) { // Read file in completely } long crc = check . getChecksum ( ) . getValue ( ) ; return crc ; }
Get the CRC of a file from an InputStream