Package java.util.zip

Examples of java.util.zip.Adler32


        for (int i = 0; i < sortedNames.length; i++) {
            sortedNames[i] = resourceNames.get(i).toLowerCase();
        }
        Arrays.sort(sortedNames);

        Adler32 cksum = new Adler32();
        try {
            DataOutputStream out = new DataOutputStream(
                    new CheckedOutputStream(NULL_OUT, cksum));

            for (String resourceName : sortedNames) {
                long lastMod = collection.getLastModified(resourceName);
                if (lastMod < 1)
                    continue;

                Long checksum = collection.getChecksum(resourceName);
                if (checksum == null)
                    continue;

                out.writeUTF(resourceName);
                out.writeLong(checksum);
            }
        } catch (IOException e) {
            // can't happen
        }

        return cksum.getValue();
    }
View Full Code Here


                if (cksum != null)
                    return cksum;

                try {
                    // We don't have an up-to-date checksum. Calculate one.
                    Long newSum = FileUtils.computeChecksum(f, new Adler32());
                    // Save the new checksum. But don't return it yet! Start
                    // back at the top of the loop and make certain the last
                    // modified time hasn't changed since we calculated the
                    // checksum.
                    synchronized (this) {
View Full Code Here

        public AbortableOutputStream(File dest) throws IOException {
            this(new BufferedOutputStream(new FileOutputStream(dest)));
        }

        public AbortableOutputStream(OutputStream out) {
            super(out, new Adler32());
            this.aborted = false;
        }
View Full Code Here

        OutputStream outStream = new FileOutputStream(outFile);
        out = new CheckedOutputStream(outStream, checksum);
    }

    protected Checksum makeChecksum() {
        return new Adler32();
    }
View Full Code Here

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

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

  /**
   * Gets the checksum of a file
   */
  private void getFileChecksum(SolrParams solrParams, SolrQueryResponse rsp) {
    Checksum checksum = new Adler32();
    File dir = new File(core.getIndexDir());
    rsp.add(CHECKSUM, getCheckSums(solrParams.getParams(FILE), dir, checksum));
    dir = new File(core.getResourceLoader().getConfigDir());
    rsp.add(CONF_CHECKSUM, getCheckSums(solrParams.getParams(CONF_FILE_SHORT), dir, checksum));
  }
View Full Code Here

        String cf = nameAndAlias.getName(i);
        File f = new File(confDir, cf);
        if (!f.exists() || f.isDirectory()) continue; //must not happen
        FileInfo info = confFileInfoCache.get(cf);
        if (info == null || info.lastmodified != f.lastModified() || info.size != f.length()) {
          if (checksum == null) checksum = new Adler32();
          info = new FileInfo(f.lastModified(), cf, f.length(), getCheckSum(checksum, f));
          confFileInfoCache.put(cf, info);
        }
        Map<String, Object> m = info.getAsMap();
        if (nameAndAlias.getVal(i) != null) m.put(ALIAS, nameAndAlias.getVal(i));
View Full Code Here

          if (offset != -1)
            channel.position(offset);
          byte[] buf = new byte[(len == -1 || len > PACKET_SZ) ? PACKET_SZ : len];
          Checksum checksum = null;
          if (useChecksum)
            checksum = new Adler32();
          ByteBuffer bb = ByteBuffer.wrap(buf);

          while (true) {
            bb.clear();
            long bytesRead = channel.read(bb);
View Full Code Here

    /**
     * Creates an ImageCacher.
     */
    public ImageCacher() {
        imageCache = new Hashtable();
        checkSum = new Adler32();
    }
View Full Code Here

        int blkId = (block==null) ? NoId : block.getId().intValue() ;
        header.putInt(blkId) ;
        header.flip() ;
        channel.write(header) ;
       
        Adler32 adler = new Adler32() ;
        adler.update(header.array()) ;

        if ( len > 0 )
        {
            // Make buffer include it's full length.
            // [TxDEV:TODO] This is the full buffer, junk and all.
            // This makes the system able to check block sizes (BlockAccess checking).
           
            int bufferLimit = buffer.limit() ;
            int bufferPosition = buffer.position() ;
            buffer.position(0) ;
            buffer.limit(bufferCapacity) ;
            // Clear top.
            for ( int i = len ; i < bufferCapacity ; i++ )
                buffer.put(i, (byte)0) ;
           
            // Write all bytes
            channel.write(buffer) ;
            adler.update(buffer.array()) ;
           
            buffer.position(bufferPosition) ;
            buffer.limit(bufferLimit) ;
        }

        // checksum
        crcTrailer.clear() ;
        Bytes.setInt((int)adler.getValue(), crcTrailer.array()) ;
        channel.write(crcTrailer) ;

        position += Overhead + len + SizeofCRC ; // header + payload + checksum
        return posn ;
    }
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.