Package java.util.zip

Examples of java.util.zip.ZipOutputStream


    private void addFileAttachment(EmailContent emailContent, String name, File file) {
        if (file != null) {
            if (reportConfig.isZipData()) {
                try {
                    File zipFile = File.createTempFile("tempZIP", ".zip");
                    ZipOutputStream zipOut = new ZipOutputStream(new FileOutputStream(zipFile));
                    zipOut.putNextEntry(new ZipEntry(name));

                    FileInputStream in = new FileInputStream(file);
                    StreamUtils.transfer(in, zipOut);
                    in.close();

                    zipOut.closeEntry();
                    zipOut.close();

                    emailContent.addAttachment(new EmailAttachment.FileAttachment(name + ".zip", zipFile));

                    filesToDelete.add(zipFile);
                }
View Full Code Here


  }
 
  private String createZipBucket(OutputStream os) throws IOException {
    if(logMINOR) Logger.minor(this, "Create a ZIP Bucket");
   
    ZipOutputStream zos = new ZipOutputStream(os);
    try {
      ZipEntry ze;

      for (ContainerElement ph : containerItems) {
        ze = new ZipEntry(ph.targetInArchive);
        ze.setTime(0);
        zos.putNextEntry(ze);
        BucketTools.copyTo(ph.data, zos, ph.data.size());
        zos.closeEntry();
      }
    } finally {
      zos.close();
    }

    return ARCHIVE_TYPE.ZIP.mimeTypes[0];
  }
View Full Code Here

   
    BufferedReader bi =
      new BufferedReader(new InputStreamReader(conn.getInputStream()));
       
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    ZipOutputStream zos = new ZipOutputStream(bos);
   
    // Process the packages
    String packageName;
    while ((packageName = bi.readLine()) != null) {     
      for (PrintStream p : progress) {
        p.println("Fetching meta data for " + packageName);
      }
      writeZipEntryForPackage(packageName, zos);
    }
    bi.close();
   
    // include the package list in the zip
    conn = getConnection(packageList);
    ZipEntry z = new ZipEntry("packageList.txt");
    BufferedInputStream bi2 = new BufferedInputStream(conn.getInputStream());
    ByteArrayOutputStream bos2 = new ByteArrayOutputStream();
    transToBAOS(bi2, bos2);
    zos.putNextEntry(z);
    zos.write(bos2.toByteArray());
    bi2.close();
   
    // Include the top level images
    String imageList = m_packageRepository.toString() + "/images.txt";
    conn = getConnection(imageList);
    bi = new BufferedReader(new InputStreamReader(conn.getInputStream()));
   
    String imageName;
    while((imageName = bi.readLine()) != null) {
      // System.err.println("Processing " + imageName);
      z = new ZipEntry(imageName);
      URLConnection conn2 = getConnection(m_packageRepository.toString()
          + "/" + imageName);
      bi2 =
        new BufferedInputStream(conn2.getInputStream());
      bos2 = new ByteArrayOutputStream();
      transToBAOS(bi2, bos2);
      zos.putNextEntry(z);
      zos.write(bos2.toByteArray());
      bi2.close();
    }
   
    // include the image list in the zip
    conn = getConnection(imageList);
    z = new ZipEntry("images.txt");
    bi2 = new BufferedInputStream(conn.getInputStream());
    bos2 = new ByteArrayOutputStream();
    transToBAOS(bi2, bos2);
    zos.putNextEntry(z);
    zos.write(bos2.toByteArray());
    bi2.close();

    zos.close();
   
    return bos.toByteArray();
  }
View Full Code Here

        Writer(OutputStream output) throws IOException {
            if (output == null) {
                throw new IllegalArgumentException("output must not be null"); //$NON-NLS-1$
            }
            this.output = new ZipOutputStream(output);
            this.output.setMethod(ZipOutputStream.DEFLATED);
            this.output.setLevel(0);
            this.output.putNextEntry(new ZipEntry(FIRST_ENTRY_NAME));
            this.output.closeEntry();
        }
View Full Code Here

        Writer(OutputStream output, boolean compress) throws IOException {
            if (output == null) {
                throw new IllegalArgumentException("output must not be null"); //$NON-NLS-1$
            }
            this.counter = new CountingOutputStream(output);
            this.output = new ZipOutputStream(counter);
            this.output.setMethod(ZipOutputStream.DEFLATED);
            if (compress == false) {
                this.output.setLevel(0);
            }
            this.output.putNextEntry(new ZipEntry(FIRST_ENTRY_NAME));
View Full Code Here

        Properties source = new Properties();
        source.setProperty("hello", "world");

        OutputStream out = new FileOutputStream(zip);
        try {
            ZipOutputStream archive = new ZipOutputStream(out);
            PropertyLoader.saveImporterProperties(archive, "default", source);
            archive.close();
        } finally {
            out.close();
        }

        PropertyLoader loader = new PropertyLoader(zip, "default");
View Full Code Here

        Properties source = new Properties();
        source.setProperty("hello", "world");

        OutputStream out = new FileOutputStream(zip);
        try {
            ZipOutputStream archive = new ZipOutputStream(out);
            PropertyLoader.saveExporterProperties(archive, "default", source);
            archive.close();
        } finally {
            out.close();
        }

        PropertyLoader loader = new PropertyLoader(zip, "default");
View Full Code Here

    }

    private void deployFatLibrary(List<File> paths, File target) throws IOException {
        prepareParent(target);
        Set<String> saw = new HashSet<String>();
        ZipOutputStream zip = new ZipOutputStream(new FileOutputStream(target));
        try {
            for (File path : paths) {
                if (path.isDirectory()) {
                    putEntry(zip, path, null, saw);
                } else {
                    mergeEntries(zip, path, saw);
                }
            }
        } finally {
            zip.close();
        }
    }
View Full Code Here

        } else {
            LOG.debug("Package into archive: {} -> {}", source, target);
            prepareParent(target);
            OutputStream output = new FileOutputStream(target);
            try {
                ZipOutputStream zip = new ZipOutputStream(output);
                putEntry(zip, source, null, new HashSet<String>());
                zip.close();
            } finally {
                output.close();
            }
        }
        return target;
View Full Code Here

      Deque<File> queue = new LinkedList<File>();
      queue.push(directory);
      OutputStream out = new FileOutputStream(zipfile);
      Closeable res = out;
      try {
        ZipOutputStream zout = new ZipOutputStream(out);
        res = zout;
        while (!queue.isEmpty()) {
          directory = queue.pop();
          for (File kid : directory.listFiles()) {
            String name = base.relativize(kid.toURI()).getPath();
            if (kid.isDirectory()) {
              queue.push(kid);
              name = name.endsWith("/") ? name : name + "/";
              zout.putNextEntry(new ZipEntry(name));
            } else {
              zout.putNextEntry(new ZipEntry(name));
              copy(kid, zout);
              zout.closeEntry();
            }
          }
        }
      } finally {
        res.close();
View Full Code Here

TOP

Related Classes of java.util.zip.ZipOutputStream

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.