Package java.util.zip

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


                String fileName = file.getPath();
                String entryName = removeBase(basePath, fileName);
                byte[] data = readFile(file);
                ZipEntry entry = new ZipEntry(entryName);
                CRC32 crc = new CRC32();
                crc.update(data);
                entry.setSize(file.length());
                entry.setCrc(crc.getValue());
                zipOut.putNextEntry(entry);
                zipOut.write(data);
                zipOut.closeEntry();
View Full Code Here


                }
                s.reset();
                seek(i);
                store.readFully(s.getBytes(), 0, pageSize);
                CRC32 crc = new CRC32();
                crc.update(s.getBytes(), 4, pageSize - 4);
                int expected = (int) crc.getValue();
                int got = s.readInt();
                long writeCounter = s.readLong();
                int key = s.readInt();
                int firstTrunkPage = s.readInt();
View Full Code Here

                throw DbException.get(ErrorCode.FILE_CORRUPTED_1, fileName);
            }
            page.reset();
            readPage(i, page);
            CRC32 crc = new CRC32();
            crc.update(page.getBytes(), 4, pageSize - 4);
            int expected = (int) crc.getValue();
            int got = page.readInt();
            if (expected == got) {
                writeCountBase = page.readLong();
                logKey = page.readInt();
View Full Code Here

        page.writeLong(getWriteCountTotal());
        page.writeInt(logKey);
        page.writeInt(logFirstTrunkPage);
        page.writeInt(logFirstDataPage);
        CRC32 crc = new CRC32();
        crc.update(page.getBytes(), 4, pageSize - 4);
        page.setInt(0, (int) crc.getValue());
        file.seek(pageSize);
        file.write(page.getBytes(), 0, pageSize);
        file.seek(pageSize + pageSize);
        file.write(page.getBytes(), 0, pageSize);
View Full Code Here

            int numRead;
            CRC32 checksum = new CRC32();
            while ((numRead = fis.read(bytes)) > 0) {
                zoStream.write(bytes, 0, numRead);
                checksum.update(bytes, 0, numRead);
            }
            zEntry.setCrc(checksum.getValue());

            fis.close();
            zoStream.closeEntry();
View Full Code Here

   
    int count = 0;
    int length = 0;
    while ((length = in.read(b)) != -1) {
      System.out.printf("#%d: len=%d\n", count, length);
      crc.update(b, 0, length);
      count ++;
    }

    in.close();
   
View Full Code Here

    String status;
    if (data.length != length) {
      status = "data.length == " + data.length + ", should be " + length;
    } else {
      CRC32 computedCrc32 = new CRC32();
      computedCrc32.update(data);
      if (computedCrc32.getValue() != crc32) {
        status = "Computed crc32 == " + computedCrc32.getValue() + ", should be " + crc32;
      } else {
        status = "OK";
      }
View Full Code Here

    return input;
  }

  public long calcCRC() {
    CRC32 crc32 = new CRC32();
    crc32.update(input);
    return crc32.getValue();
  }

  // getters  Covers ProductDefinitions 0-14 first
View Full Code Here

        ArrayList<Integer> duplicate = new ArrayList<Integer>();
        CRC32 crc32 = new CRC32();
        for (int i = 0; i < products.size(); i++) {
          Grib2Product product = products.get( i );
          crc32.reset();
          crc32.update(product.getPDS().getPdsVars().getPDSBytes());

          // heres a way to get a byte array for CRC from other values we need for duplicate checking
          ByteBuffer bb = ByteBuffer.allocate(12);
          bb.putInt( product.getDiscipline());
          bb.putLong( product.getRefTime());
View Full Code Here

          // heres a way to get a byte array for CRC from other values we need for duplicate checking
          ByteBuffer bb = ByteBuffer.allocate(12);
          bb.putInt( product.getDiscipline());
          bb.putLong( product.getRefTime());
          crc32.update(bb.array());

          long crcv = crc32.getValue();
          Integer recnum = pdsMap.get(crcv);
          // duplicate found
          if ( recnum != null) {
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.