Package java.util.zip

Examples of java.util.zip.CheckedOutputStream


            try {
                socket = new Socket(address, syncPort);
                LOG.info("sync connected to " + socket.getInetAddress().getHostAddress() + " port " + socket.getLocalPort());

                final CRC32 crc32 = new CRC32();
                final DataOutput output = new DataOutputStream(new CheckedOutputStream(socket.getOutputStream(), crc32));
                final DataInput input = new DataInputStream(socket.getInputStream());
                output.writeByte(INIT);
                long logId = input.readLong();
                do {
                    final long nextLogId = logId + 1;
View Full Code Here


    crc32 = new CRC32();
    final PackOutputStream out = new PackOutputStream(
      writeMonitor,
      isIndexDisabled()
        ? packStream
        : new CheckedOutputStream(packStream, crc32),
      this);

    long objCnt = getObjectCount();
    stats.totalObjects = objCnt;
    beginPhase(PackingPhase.WRITING, writeMonitor, objCnt);
View Full Code Here

     * @throws IOException if a problem is encountered writing the output
     */
    public synchronized void encode(OutputStream out)
    throws IOException {
        Checksum csum = new CRC32();
        out = new CheckedOutputStream(out, csum);
   
        out.write(SIGNATURE);

        writeIhdrChunk(out, csum);

View Full Code Here

    File zipFile = new Path(targetZipFilePath).toFile();

    if (FileUtil.createFile(zipFile, false)) {
      FileOutputStream out = new FileOutputStream(zipFile);
      CheckedOutputStream cs = new CheckedOutputStream(out, new Adler32());
      ZipOutputStream zout = new ZipOutputStream(
          new BufferedOutputStream(cs));
      zip(zout, inputRoot, "", cs);
      zout.close();
    } else
View Full Code Here

            try {
                socket = new Socket(address, syncPort);
                LOG.info("sync connected to " + socket.getInetAddress().getHostAddress() + " port " + socket.getLocalPort());

                CRC32 crc32 = new CRC32();
                DataOutput output = new DataOutputStream(new CheckedOutputStream(socket.getOutputStream(), crc32));
                DataInput input = new DataInputStream(socket.getInputStream());
                output.writeByte(INIT);
                long logId = input.readLong();
                do {
                    long nextLogId = logId + 1;
View Full Code Here

        manifest.append((String)aEnum.nextElement());
        manifest.append("\n");
      }
      manifest.append("\n");
               
        bufferedOutputStream = new BufferedOutputStream(new CheckedOutputStream(new FileOutputStream(filename), new Adler32()));
        zipFile = new ZipOutputStream(bufferedOutputStream);

            while (liste.hasMoreElements()) {
                file = (FileListElement)liste.nextElement();
View Full Code Here

    private static String SOME_KLASS = ".Some";
   
    static byte[] getManifestAsBytes(int nchars) throws IOException {
        crc.reset();
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        CheckedOutputStream cos = new CheckedOutputStream(baos, crc);
        PrintStream ps = new PrintStream(cos);
        ps.println("Manifest-Version: 1.0");
        ps.print("Main-Class: ");
        for (int i = 0 ; i < nchars - SOME_KLASS.length(); i++) {
            ps.print(i%10);
        }
        ps.println(SOME_KLASS);
        cos.flush();
        cos.close();
        ps.close();
        return baos.toByteArray();
    }
View Full Code Here

  }

  public void writeToFile(Path loc, JobConf job, Checksum crc)
      throws IOException {
    final FileSystem rfs = FileSystem.getLocal(job).getRaw();
    CheckedOutputStream chk = null;
    final FSDataOutputStream out = rfs.create(loc);
    try {
      if (crc != null) {
        crc.reset();
        chk = new CheckedOutputStream(out, crc);
        chk.write(buf.array());
        out.writeLong(chk.getChecksum().getValue());
      } else {
        out.write(buf.array());
      }
    } finally {
      if (chk != null) {
        chk.close();
      } else {
        out.close();
      }
    }
  }
View Full Code Here

     * @param snapShot the file to store snapshot into
     */
    public void serialize(DataTree dt, Map<Long, Integer> sessions, File snapShot)
            throws IOException {
        OutputStream sessOS = new BufferedOutputStream(new FileOutputStream(snapShot));
        CheckedOutputStream crcOut = new CheckedOutputStream(sessOS, new Adler32());
        //CheckedOutputStream cout = new CheckedOutputStream()
        OutputArchive oa = BinaryOutputArchive.getArchive(crcOut);
        FileHeader header = new FileHeader(SNAP_MAGIC, VERSION, dbId);
        serialize(dt,sessions,oa, header);
        long val = crcOut.getChecksum().getValue();
        oa.writeLong(val, "val");
        oa.writeString("/", "path");
        sessOS.flush();
        crcOut.close();
        sessOS.close();
    }
View Full Code Here

     * @param snapShot the file to store snapshot into
     */
    public void serialize(DataTree dt, Map<Long, Integer> sessions, File snapShot)
            throws IOException {
        OutputStream sessOS = new BufferedOutputStream(new FileOutputStream(snapShot));
        CheckedOutputStream crcOut = new CheckedOutputStream(sessOS, new Adler32());
        //CheckedOutputStream cout = new CheckedOutputStream()
        OutputArchive oa = BinaryOutputArchive.getArchive(crcOut);
        FileHeader header = new FileHeader(SNAP_MAGIC, VERSION, dbId);
        serialize(dt,sessions,oa, header);
        long val = crcOut.getChecksum().getValue();
        oa.writeLong(val, "val");
        oa.writeString("/", "path");
        sessOS.flush();
        crcOut.close();
        sessOS.close();
    }
View Full Code Here

TOP

Related Classes of java.util.zip.CheckedOutputStream

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.