Package java.util.zip

Examples of java.util.zip.Adler32


      prop.put("filewatcher.lockExtention", "*.lck");
      doPublish(prop, deliverDat, deliverGif, absSubPath);
   }
  
   long getChecksum(InputStream is) throws IOException {
      CheckedInputStream cis = new CheckedInputStream(is, new Adler32());
      byte[] tempBuf = new byte[128];
      while (cis.read(tempBuf) >= 0) {
      }
      return cis.getChecksum().getValue();
   }
View Full Code Here


         throw new IOException(Messages.getString("ApplicationLauncher.tunnelRequiredButNoEventHandler")); //$NON-NLS-1$
    }

    private long generateChecksum(File f) throws IOException {

        Adler32 alder = new Adler32();
        CheckedInputStream in = new CheckedInputStream(new FileInputStream(f), alder);
        try {
            byte[] buf = new byte[4096];
            int read = 0;
            while ((read = in.read(buf)) > -1)
                ;

            alder = (Adler32) in.getChecksum();

            return alder.getValue();
        } finally {
            in.close();
        }
    }
View Full Code Here

     * @param f
     * @return long
     * @throws IOException
     */
    public static long generateChecksum(File f) throws IOException {
        Adler32 alder = new Adler32();
        FileInputStream fin = new FileInputStream(f);
        CheckedInputStream in = new CheckedInputStream(fin, alder);
        byte[] buf = new byte[32768];
        Util.readFullyIntoBuffer(in, buf);
        alder = (Adler32) in.getChecksum();
        try {
            in.close();
        } catch (IOException ex) {
        }
        try {
            fin.close();
        } catch (IOException ex1) {
        }
        return alder.getValue();
    }
View Full Code Here

    {
      inStream = new FileInputStream(file);
      long size = file.length();
      CRC32 crc32 = null;
      MessageDigest md = null;
      Adler32 adler32 = null;
      if (algo.equalsIgnoreCase("CRC32"))
        crc32 = new CRC32();
      else if (algo.equalsIgnoreCase("Adler32"))
        adler32 = new Adler32();
      else md = MessageDigest.getInstance(algo);
      byte [] buf = new byte[BUF_SIZE];
      int readed = -1;
      if (listener != null) listener.notify(new ProgNotify(ProgNotify.START, 0, new Long(size).toString()));
      long total = size;
      boolean bAbort = false;
      while(size != 0)
      {
        if ((readed = inStream.read(buf)) >= 0)
        {
          if (crc32 != null) crc32.update(buf, 0, readed);
          else if (adler32 != nulladler32.update(buf, 0, readed);
          else md.update(buf, 0, readed);
         
          assert size <= readed;
          size -= readed;
          if (listener != null)
          {
            if (bAbort = listener.notify(new ProgNotify(ProgNotify.RUN, (int)(1000L - (size*1000L)/total), null)))
              break;
          }
        }
        else break;
      }
      if (bAbort)
      {
        if (listener != null) listener.notify(new ProgNotify(ProgNotify.ABORT, 0, null));
      }
      else
      {
        if (crc32 != null) m_byteArray = longToByteArray4(crc32.getValue());
        else if (adler32 != null) m_byteArray = longToByteArray4(adler32.getValue());
        else m_byteArray = md.digest();
     
        int index = 0;
        StringBuilder str = new StringBuilder();
        String temp = null;
View Full Code Here

     * @param adler the number to use as starting point for the Adler-32 algorithm
     */
    public Adler32Ext(final int adler) {
        super();
        this.adler=adler;
        this.intern = new Adler32();
        setAdlerRef(this.adler);
    }
View Full Code Here

        ? LZ4Factory.fastestInstance().fastCompressor()
        : LZ4Factory.fastestInstance().highCompressor();
    final Checksum checksum;
    switch (randomInt(2)) {
    case 0:
      checksum = new Adler32();
      break;
    case 1:
      checksum = new CRC32();
      break;
    default:
View Full Code Here

          System.out.println("EOF reached after " + count + " txns.");
        }

        return;
      }
      Checksum crc = new Adler32();
      crc.update(bytes, 0, bytes.length);
      if (crcValue != crc.getValue())
      {
        throw new IOException("CRC doesn't match " + crcValue + " vs "
            + crc.getValue());
      }
      InputArchive iab = BinaryInputArchive
          .getArchive(new ByteArrayInputStream(bytes));
      TxnHeader hdr = new TxnHeader();
      Record txn = SerializeUtils.deserializeTxn(iab, hdr);
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

    Inflater inflateDiction = new Inflater();
    inflateDiction.setInput(outPutDiction);
    if (inflateDiction.needsDictionary() == true) {
      // getting the checkSum value through the Adler32 class
      Adler32 adl = new Adler32();
      adl.update(dictionaryArray);
      long checkSumR = adl.getValue();
      assertTrue(
          "the checksum value returned by getAdler() is not the same as the checksum returned by creating the adler32 instance",
          checkSumR == inflateDiction.getAdler());
    }
  }
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.