Package java.util.zip

Examples of java.util.zip.CheckedInputStream


      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


    }

    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

     * @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) {
View Full Code Here

     */

    void initializeFile() throws Exception
    {
       // FILE SIZE
        CheckedInputStream cis = null;

        File site = new File(filename);
        fileSize = site.length();

       // File Checksum
        try {
            cis = new CheckedInputStream( new FileInputStream(filename), new CRC32());
            byte[] buf = new byte[128];

            while(cis.read(buf) >= 0) {
            }

        checksum = cis.getChecksum().getValue();
       
        cis.close();     

        } catch (Exception e) {
            logger.log(Level.WARNING, "Something went wrong at initialize file (crc32)", e);
        }
        // NEXT
View Full Code Here

    }
  }

  private static long crcFile(File file) throws IOException {

    CheckedInputStream cis = null;
    long fileSize = 0;
    cis = new CheckedInputStream(new FileInputStream(file), new CRC32());
    try {
      byte[] buf = new byte[4 * 1024];
      while (cis.read(buf) >= 0)
        ;

      return cis.getChecksum().getValue();
    } finally {
      cis.close();
    }
  }
View Full Code Here

        if (file.isDirectory()) {
            throw new IllegalArgumentException("Checksums can't be computed on directories");
        }
        InputStream in = null;
        try {
            in = new CheckedInputStream(new FileInputStream(file), checksum);
            IOUtils.copy(in, new NullOutputStream());
        } finally {
            IOUtils.closeQuietly(in);
        }
        return checksum;
View Full Code Here

      final int size = partitions * MAP_OUTPUT_INDEX_RECORD_LENGTH;

      buf = ByteBuffer.allocate(size);
      if (crc != null) {
        crc.reset();
        CheckedInputStream chk = new CheckedInputStream(in, crc);
        IOUtils.readFully(chk, buf.array(), 0, size);
        if (chk.getChecksum().getValue() != in.readLong()) {
          throw new ChecksumException("Checksum error reading spill index: " +
                                indexFileName, -1);
        }
      } else {
        IOUtils.readFully(in, buf.array(), 0, size);
View Full Code Here

    private int maxOpSize;

    public Reader(DataInputStream in,int logVersion,int maxOpSize) {
      this.logVersion = logVersion;
      this.checksum = new PureJavaCrc32();
      this.in = new DataInputStream(new CheckedInputStream(in, this.checksum));
      this.cache = new OpInstanceCache();
      this.maxOpSize = maxOpSize;
    }
View Full Code Here

    @Override
    public String write(InputStream in) throws MicroKernelException {
        try {
            final Hasher hasher = Hashing.sha256().newHasher();
            Blob blob = store.createBlob(
                    new CheckedInputStream(in, new Checksum() {
                        @Override
                        public void update(byte[] b, int off, int len) {
                            hasher.putBytes(b, off, len);
                        }
                        @Override
View Full Code Here

   * @tests java.util.zip.CheckedInputStream#CheckedInputStream(java.io.InputStream,
   *        java.util.zip.Checksum)
   */
  public void test_ConstructorLjava_io_InputStreamLjava_util_zip_Checksum() throws Exception {
        InputStream checkInput = Support_Resources.getStream("hyts_checkInput.txt");
        CheckedInputStream checkIn = new CheckedInputStream(checkInput, new CRC32());
        assertEquals("constructor of checkedInputStream has failed", 0, checkIn.getChecksum()
                .getValue());
        checkInput.close();
    }
View Full Code Here

TOP

Related Classes of java.util.zip.CheckedInputStream

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.