Package java.util.zip

Examples of java.util.zip.CheckedInputStream


        // System.out.println(inputChecksum.getValue());
    }

    private static StringBuffer readChecksummedFile(int i) throws Exception {
        CRC32 inputChecksum = new CRC32();
        CheckedInputStream in = new CheckedInputStream(new FileInputStream("test" + i % 3 + ".data"), inputChecksum);
        BufferedReader reader = new BufferedReader(new InputStreamReader(in, Util.ENCODING));

        StringBuffer buf = new StringBuffer();
        String line;
        while ((line = reader.readLine()) != null) {
View Full Code Here


    private void syncConnection(final Socket connection, final int readTimeout) {
        try {
            final CRC32 crc32 = new CRC32();
            final DataOutput output = new DataOutputStream(connection.getOutputStream());
            final DataInput input = new DataInputStream(new CheckedInputStream(connection.getInputStream(), crc32));

            if (input.readByte() != INIT) {
                return;
            }
View Full Code Here

            this.checksum = checksum;
        }

        @Override
        InputStream decorate(final InputStream wrapped) throws IOException {
            return new CheckedInputStream(wrapped, this.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

        this.checksum = null;
      }

      if (this.checksum != null) {
        this.in = new DataInputStream(
            new CheckedInputStream(in, this.checksum));
      } else {
        this.in = in;
      }
      this.limiter = limiter;
      this.cache = new OpInstanceCache();
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

        this.checksum = null;
      }

      if (this.checksum != null) {
        this.in = new DataInputStream(
            new CheckedInputStream(in, this.checksum));
      } else {
        this.in = in;
      }
    }
View Full Code Here

            this.checksum = checksum;
        }

        @Override
        InputStream decorate(final InputStream wrapped) throws IOException {
            return new CheckedInputStream(wrapped, this.checksum);
        }
View Full Code Here

        if (snap == null) {
            return -1L;
        }
        LOG.info("Reading snapshot " + snap);
        InputStream snapIS = new BufferedInputStream(new FileInputStream(snap));
        CheckedInputStream crcIn = new CheckedInputStream(snapIS, new Adler32());
        InputArchive ia=BinaryInputArchive.getArchive(crcIn);
        deserialize(dt,sessions, ia);
        long checkSum = crcIn.getChecksum().getValue();
        long val = ia.readLong("val");
        if (val != checkSum) {
            throw new IOException("CRC corruption in snapshot :  " + snap);
        }
        snapIS.close();
        crcIn.close();
        dt.lastProcessedZxid = Util.getZxidFromName(snap.getName(), "snapshot");
        return dt.lastProcessedZxid;
    }
View Full Code Here

            this.checksum = checksum;
        }

        @Override
        InputStream getDecompressingInputStream(final InputStream wrapped) throws IOException {
            return new CheckedInputStream(wrapped, this.checksum);
        }
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.