@Test public void testCompute() throws Exception { assertEquals("0", new CRC32ChecksumCompute().compute(new NullInputStream(0), new TransferStatus()).hash); assertEquals("d202ef8d", new CRC32ChecksumCompute().compute(new NullInputStream(1L), new TransferStatus()).hash); }
@Override public Checksum compute(final InputStream in, final TransferStatus status) throws ChecksumException { final InputStream normalized = this.normalize(in, status); final CRC32 crc32 = new CRC32(); try { byte[] buffer = new byte[16384]; int bytesRead; while((bytesRead = normalized.read(buffer, 0, buffer.length)) != -1) { crc32.update(buffer, 0, bytesRead); } } catch(IOException e) { throw new ChecksumException(LocaleFactory.localizedString("Checksum failure", "Error"), e.getMessage(), e); } finally { IOUtils.closeQuietly(normalized); } return new Checksum(HashAlgorithm.crc32, Long.toHexString(crc32.getValue())); }
CRC32ChecksumCompute extends AbstractChecksumCompute { @Override public Checksum compute(final InputStream in, final TransferStatus status) throws ChecksumException { final InputStream normalized = this.normalize(in, status); final CRC32 crc32 = new CRC32(); try { byte[] buffer = new byte[16384]; int bytesRead; while((bytesRead = normalized.read(buffer, 0, buffer.length)) != -1) { crc32.update(buffer, 0, bytesRead); } } catch(IOException e) { throw new ChecksumException(LocaleFactory.localizedString("Checksum failure", "Error"), e.getMessage(), e); } finally { IOUtils.closeQuietly(normalized); } return new Checksum(HashAlgorithm.crc32, Long.toHexString(crc32.getValue())); } }
CRC32ChecksumCompute extends AbstractChecksumCompute { @Override public Checksum compute(final InputStream in, final TransferStatus status) throws ChecksumException { final InputStream normalized = this.normalize(in, status); final CRC32 crc32 = new CRC32(); try { byte[] buffer = new byte[16384]; int bytesRead; while((bytesRead = normalized.read(buffer, 0, buffer.length)) != -1) { crc32.update(buffer, 0, bytesRead); } } catch(IOException e) { throw new ChecksumException(LocaleFactory.localizedString("Checksum failure", "Error"), e.getMessage(), e); } finally { IOUtils.closeQuietly(normalized); } return new Checksum(HashAlgorithm.crc32, Long.toHexString(crc32.getValue())); }  }
CRC32ChecksumCompute extends AbstractChecksumCompute { @Override public Checksum compute(final InputStream in, final TransferStatus status) throws ChecksumException { final InputStream normalized = this.normalize(in, status); final CRC32 crc32 = new CRC32(); try { byte[] buffer = new byte[16384]; int bytesRead; while((bytesRead = normalized.read(buffer, 0, buffer.length)) != -1) { crc32.update(buffer, 0, bytesRead); } } catch(IOException e) { throw new ChecksumException(LocaleFactory.localizedString("Checksum failure", "Error"), e.getMessage(), e); } finally { IOUtils.closeQuietly(normalized); } return new Checksum(HashAlgorithm.crc32, Long.toHexString(crc32.getValue())); }  @Override Checksum compute(final InputStream in, final TransferStatus status); }
CRC32ChecksumCompute extends AbstractChecksumCompute { @Override public Checksum compute(final InputStream in, final TransferStatus status) throws ChecksumException { final InputStream normalized = this.normalize(in, status); final CRC32 crc32 = new CRC32(); try { byte[] buffer = new byte[16384]; int bytesRead; while((bytesRead = normalized.read(buffer, 0, buffer.length)) != -1) { crc32.update(buffer, 0, bytesRead); } } catch(IOException e) { throw new ChecksumException(LocaleFactory.localizedString("Checksum failure", "Error"), e.getMessage(), e); } finally { IOUtils.closeQuietly(normalized); } return new Checksum(HashAlgorithm.crc32, Long.toHexString(crc32.getValue())); }  @Override Checksum compute(final InputStream in, final TransferStatus status);  }