Package java.util.zip

Examples of java.util.zip.CRC32.reset()


    private static void testArray(final StringBuffer buf) {
        final byte[] data = buf.toString().getBytes();

        final CRC32 inputChecksum = new CRC32();
        inputChecksum.reset();
        inputChecksum.update(data);

        // System.out.println(inputChecksum.getValue());
    }
View Full Code Here


        return data;
    }

    private static void checksumArray(final byte[] data) {
        final CRC32 inputChecksum = new CRC32();
        inputChecksum.reset();
        inputChecksum.update(data);

        // System.out.println(inputChecksum.getValue());
    }
View Full Code Here

                    final File file = Util.logFile(nextLogId);
                    if (file.exists() && server.getLogger().isWritten(nextLogId)) {
                        logId++;

                        output.writeByte(RECOVERY_LOG);
                        crc32.reset();
                        output.writeLong(logId);

                        LOG.info("sending recovery file: " + file.getName());
                        final BufferedInputStream fileInput = new BufferedInputStream(new FileInputStream(file));
View Full Code Here

            output.writeLong(lastId);
            do {
                if (input.readByte() != RECOVERY_LOG) {
                    return;
                }
                crc32.reset();
                final long logId = input.readLong();
                final File file = Util.tmpLogFile(logId);
                LOG.info("syncing recovery file: " + file.getName());
                final BufferedOutputStream fileOutput = new BufferedOutputStream(new FileOutputStream(file));
View Full Code Here

    long end = 0;
    long hash = 0;
    long diff = 0;
    long delayMicro = 0;

    chksum.reset();
    chksum.update(b);
    long prevhash = chksum.getValue();
    for (int i = 0; i < 10; i++)
    {
      start = System.nanoTime();
View Full Code Here

    chksum.update(b);
    long prevhash = chksum.getValue();
    for (int i = 0; i < 10; i++)
    {
      start = System.nanoTime();
      chksum.reset();
      chksum.update(b);
      hash = chksum.getValue();
      end = System.nanoTime();
      assert(prevhash == hash);
      diff += (end - start);
View Full Code Here

     * throws IOException if there was a problem copying */
  public static Long copyFile(InputStream in, OutputStream out) throws IOException
  {
    final CRC32 checksum = verify ? new CRC32() : null;
    if (verify) {
      checksum.reset();
    }
    byte[] buffer = new byte[bufferSize];
    int bytesRead;
    if (verify)
      while ((bytesRead = in.read(buffer)) >= 0) {
View Full Code Here

  /** Returns the CRC checksum of denoted file */
  public static Long createChecksum(File file) throws IOException {
    final InputStream in = openFileStream(file);
    final CRC32 checksum = new CRC32();
    checksum.reset();
    final byte[] buffer = new byte[bufferSize];
    int bytesRead;
    while ((bytesRead = in.read(buffer)) >= 0) {
      checksum.update(buffer, 0, bytesRead);
    }
View Full Code Here

      rand.nextBytes(b);
      stm.write(b);
     
      crc.update(b);
      crcs[i-1] = crc.getValue();
      crc.reset();
    }
    // Write partial block.
    b = new byte[(int)BLOCK_SIZE/2 - 1];
    rand.nextBytes(b);
    stm.write(b);
View Full Code Here

    for (int i = 1; i < numBlocks; i++) {
      LOG.info("Writing block number " + i + " (primary host)");
     
      rand.nextBytes(b);
      stm.write(b);
      crc.reset();
      crc.update(b);
      crcs[i] = crc.getValue();
    }
    stm.close();
    Thread.sleep(1000);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.