Package java.util.zip

Examples of java.util.zip.Adler32


        int typeId  = header.getInt() ;
        int len     = header.getInt() ;
        int ref     = header.getInt() ;
        int blockId = header.getInt() ;
       
        Adler32 adler = new Adler32() ;
        adler.update(header.array()) ;

        ByteBuffer bb = ByteBuffer.allocate(len) ;
        lenRead = channel.read(bb) ;
        if ( lenRead != len)
            throw new TDBTransactionException("Failed to read the journal entry: wanted "+len+" bytes, got "+lenRead) ;
        adler.update(bb.array()) ;
        bb.rewind() ;
        // checksum
        crcTrailer.clear() ;
        lenRead = channel.read(crcTrailer) ;
        if ( lenRead != SizeofCRC )
            throw new TDBTransactionException("Failed to read block checksum (got "+lenRead+" bytes, not "+SizeofCRC+").") ;
        int checksum = Bytes.getInt(crcTrailer.array()) ;
        if ( checksum != (int)adler.getValue() )
          throw new TDBTransactionException("Checksum error reading from the Journal.") ;

        JournalEntryType type = JournalEntryType.type(typeId) ;
        FileRef fileRef = FileRef.get(ref) ;
View Full Code Here


    /** Faster than CRC32, nearly as good.
     * @see Adler32
     */
    public static long adler32(byte[] bytes)
    {
        return crc(new Adler32(), bytes) ;
    }
View Full Code Here

            return;
        }
        if ("CRC".equals(algorithm)) {
            checksum = new CRC32();
        } else if ("ADLER".equals(algorithm)) {
            checksum = new Adler32();
        } else {
            throw new BuildException(new NoSuchAlgorithmException());
        }
    }
View Full Code Here

        System.out.println("CRC took " + new TimeValue(System.currentTimeMillis() - start));
    }

    private static void adler(long dataSize) {
        long start = System.currentTimeMillis();
        Adler32 crc = new Adler32();
        byte[] data = new byte[BATCH_SIZE];
        long iter = dataSize / BATCH_SIZE;
        for (long i = 0; i < iter; i++) {
            crc.update(data);
        }
        crc.getValue();
        System.out.println("Adler took " + new TimeValue(System.currentTimeMillis() - start));
    }
View Full Code Here

                    this.digest = null;
                } else {
//                    this.digest = new CRC32();
                    // adler is faster, and we compare on length as well, should be enough to check for difference
                    // between files
                    this.digest = new Adler32();
                }
            } else {
                this.digest = null;
            }
        }
View Full Code Here

    logger = logger.branch(TreeLogger.DEBUG, "Computing CSS class replacements");

    SortedSet<JClassType> cssResourceSubtypes = computeOperableTypes(logger);

    if (classPrefix == null) {
      Adler32 checksum = new Adler32();
      for (JClassType type : cssResourceSubtypes) {
        checksum.update(Util.getBytes(type.getQualifiedSourceName()));
      }
      classPrefix = "G"
          + Long.toString(checksum.getValue(), Character.MAX_RADIX);
    }

    int count = 0;
    for (JClassType type : cssResourceSubtypes) {
      Map<JMethod, String> replacements = new IdentityHashMap<JMethod, String>();
View Full Code Here

    /**
     * creates a checksum alogrithm to be used
     * @return the checksum used for this txnlog
     */
    protected Checksum makeChecksumAlgorithm(){
        return new Adler32();
    }
View Full Code Here

        /**
         * create a checksum algorithm
         * @return the checksum algorithm
         */
        protected Checksum makeChecksumAlgorithm(){
            return new Adler32();
        }
View Full Code Here

            contents = file.getContents();
        } catch (CoreException e) {
            throw new CausedIOException("Failed to calculate checksum.", e);
        }

        CheckedInputStream in = new CheckedInputStream(contents, new Adler32());
        try {
            IOUtils.copy(in, new NullOutputStream());
        } catch (IOException e) {
            throw new CausedIOException("Failed to calculate checksum.", e);
        } finally {
View Full Code Here

     
      this.fileOutputStream = new FileOutputStream(file);
      this.fileChannel = this.fileOutputStream.getChannel();

      if (includeChecksum)
        checksum = new Adler32();
    }
View Full Code Here

TOP

Related Classes of java.util.zip.Adler32

Copyright © 2018 www.massapicom. 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.