Examples of ZipOutputStream


Examples of java.util.zip.ZipOutputStream

      JSFile objFile = new JSFile(pstrPathName);
      if (this.isTarget() == true) {
        if (objFile.exists()) {
          objFile.delete();
        }
        objZipOutputStream = new ZipOutputStream(new FileOutputStream(pstrPathName));
        flgResult = true;
        logger.debug(String.format("Zip-File '%1$s' created", pstrPathName));
      }
      else {
        if (objFile.exists()) {
View Full Code Here

Examples of java.util.zip.ZipOutputStream

    return null;
  }

  @Override
  public OutputStream getOutputStream(String strFileName) {
    ZipOutputStream objZOS = null;
    ZipEntry objZE = objWorkingDirectory.getEntry(strFileName);
    if (objZE != null) {
      try {
        FileOutputStream objFOS = new FileOutputStream(objWorkingDirectory.getName());
        objZOS = new ZipOutputStream(objFOS);
        objZOS.putNextEntry(objZE);
      }
      catch (Exception e) {
        e.printStackTrace();
        throw new JobSchedulerException();
      }
View Full Code Here

Examples of java.util.zip.ZipOutputStream

  public void writeZipFile(File directoryToZip, List<File> fileList, FileOutputStream fos) {

    try {
      //FileOutputStream fos = new FileOutputStream(directoryToZip.getName() + ".zip");
      ZipOutputStream zos = new ZipOutputStream(fos);

      for (File file : fileList) {
        if (!file.isDirectory()) { // we only zip files, not directories
          addToZip(directoryToZip, file, zos);
        } else {
//          String zipFilePath = file.getCanonicalPath().substring(directoryToZip.getCanonicalPath().length() + 1,
//              file.getCanonicalPath().length());
//          //log.debug("Writing '" + zipFilePath + "' to zip file");
//          ZipEntry zipEntry = new ZipEntry(zipFilePath);
//          zos.putNextEntry(zipEntry);
        }
      }

      zos.close();
      fos.close();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    } catch (IOException e) {
      e.printStackTrace();
View Full Code Here

Examples of java.util.zip.ZipOutputStream

 
  // build the jar
  // VFS currently does not support building zip files -> use java's ZipOutputStream
  private void buildJar(String newJar) throws IOException
  {
    ZipOutputStream out = new ZipOutputStream(new FileOutputStream(newJar ));
    FileSystemManager fsManager = VFS.getManager();
    for (String jar : _jar2class.keySet())
    {
      FileObject jarFile;
      if (jar.endsWith(".jar"))
        jarFile = fsManager.resolveFile( "jar:"+jar );
      else
        jarFile = fsManager.resolveFile( jar );
       
        for (String file : _jar2class.get(jar))
        {
          file = file.replaceAll("\\.", "/");
          file += ".class";
          FileObject f = fsManager.resolveFile(jarFile, file);
          if (f.exists())
            addFile(f, file, out);
          else
            System.out.println("file not found "+f);
       
       
    }
    out.close();
  }
View Full Code Here

Examples of net.sf.jazzlib.ZipOutputStream

      String name = target.getName();
      if (target instanceof LocalImpl)
        name = ((LocalImpl)target).getBasefile().getAbsolutePath();
      throw new OLATRuntimeException(ZipUtil.class, "Error getting output stream for file: " + name, null);
    }
    ZipOutputStream zipOut = new ZipOutputStream(out);
    for (Iterator<VFSItem> iter = vfsFiles.iterator(); iter.hasNext();) {
      success = success && addToZip(iter.next(), "", zipOut);
    }
    FileUtils.closeSafely(zipOut);
    return success;
View Full Code Here

Examples of org.apache.tools.zip.ZipOutputStream

            String action = doUpdate ? "Updating " : "Building ";

            log(action + archiveType + ": " + zipFile.getAbsolutePath());

            ZipOutputStream zOut =
                new ZipOutputStream(new FileOutputStream(zipFile));
            zOut.setEncoding(encoding);
            try {
                if (doCompress) {
                    zOut.setMethod(ZipOutputStream.DEFLATED);
                } else {
                    zOut.setMethod(ZipOutputStream.STORED);
                }
                initZipOutputStream(zOut);

                // Add the explicit filesets to the archive.
                for (int i = 0; i < fss.length; i++) {
                    if (addThem[i].length != 0) {
                        addResources(fss[i], addThem[i], zOut);
                    }
                }
               
                if (doUpdate) {
                    addingNewFiles = false;
                    ZipFileSet oldFiles = new ZipFileSet();
                    oldFiles.setSrc(renamedFile);

                    for (int i = 0; i < addedFiles.size(); i++) {
                        PatternSet.NameEntry ne = oldFiles.createExclude();
                        ne.setName((String) addedFiles.elementAt(i));
                    }
                    DirectoryScanner ds =
                        oldFiles.getDirectoryScanner(getProject());
                    String[] f = ds.getIncludedFiles();
                    Resource[] r = new Resource[f.length];
                    for (int i = 0; i < f.length; i++) {
                        r[i] = ds.getResource(f[i]);
                    }
                   
                    addResources(oldFiles, r, zOut);
                }
                finalizeZipOutputStream(zOut);

                // If we've been successful on an update, delete the
                // temporary file
                if (doUpdate) {
                    if (!renamedFile.delete()) {
                        log ("Warning: unable to delete temporary file " +
                             renamedFile.getName(), Project.MSG_WARN);
                    }
                }
                success = true;
            } finally {
                // Close the output stream.
                try {
                    if (zOut != null) {
                        zOut.close();
                    }
                } catch (IOException ex) {
                    // If we're in this finally clause because of an
                    // exception, we don't really care if there's an
                    // exception when closing the stream. E.g. if it
View Full Code Here

Examples of org.beangle.commons.archiver.zip.ZipOutputStream

  // 文件压缩
  public static File zip(List<String> fileNames, String zipPath, String encoding) {
    try {
      FileOutputStream f = new FileOutputStream(zipPath);
      ZipOutputStream out = new ZipOutputStream(new DataOutputStream(f));
      // FIXME
      out.setEncoding(encoding);
      for (int i = 0; i < fileNames.size(); i++) {
        String fileName = fileNames.get(i);
        DataInputStream in = new DataInputStream(new FileInputStream(fileName));
        String entryName = StringUtils.substringAfterLast(fileName, File.separator);
        out.putNextEntry(new ZipEntry(entryName));
        int c;
        while ((c = in.read()) != -1) {
          out.write(c);
        }
        in.close();
      }
      out.close();
      return new File(zipPath);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }
View Full Code Here

Examples of org.codehaus.plexus.archiver.zip.ZipOutputStream

        if ( !createEmpty )
        {
            return true;
        }

        ZipOutputStream zOut = null;
        try
        {
            getLogger().debug( "Building MANIFEST-only jar: "
                               + getDestFile().getAbsolutePath() );
            zOut = new ZipOutputStream( new FileOutputStream( getDestFile() ) );

            zOut.setEncoding( getEncoding() );
            if ( isCompress() )
            {
                zOut.setMethod( ZipOutputStream.DEFLATED );
            }
            else
            {
                zOut.setMethod( ZipOutputStream.STORED );
            }
            initZipOutputStream( zOut );
            finalizeZipOutputStream( zOut );
        }
        catch ( IOException ioe )
        {
            throw new ArchiverException( "Could not create almost empty JAR archive"
                                         + " (" + ioe.getMessage() + ")", ioe );
        }
        finally
        {
            // Close the output stream.
            try
            {
                if ( zOut != null )
                {
                    zOut.close();
                }
            }
            catch ( IOException ex )
            {
            }
View Full Code Here

Examples of org.jahia.utils.zip.ZipOutputStream

        exportSites(outputStream, params, l);
    }

    public void exportSites(OutputStream outputStream, Map<String, Object> params, List<JahiaSite> sites)
            throws JahiaException, RepositoryException, IOException, SAXException, JDOMException {
        ZipOutputStream zout = new ZipOutputStream(outputStream);

        ZipEntry anEntry = new ZipEntry(EXPORT_PROPERTIES);
        zout.putNextEntry(anEntry);
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(zout));
        bw.write("JahiaRelease = " + Jahia.getReleaseNumber() + "\n");
        bw.write("Patch = " + Jahia.getPatchNumber() + "\n");
        bw.write("BuildNumber = " + Jahia.getBuildNumber() + "\n");
        bw.write("ExportDate = " + new SimpleDateFormat(ImportExportService.DATE_FORMAT).format(new Date()) + "\n");
        bw.flush();

        // Add system site for export
        boolean systemFound = false;
        for (JahiaSite jahiaSite : sites) {
            if (jahiaSite.getSiteKey().equals("systemsite")) {
                systemFound = true;
                break;
            }
        }
        if (!systemFound) {
            anEntry = new ZipEntry("systemsite.zip");
            zout.putNextEntry(anEntry);
            exportSystemSite(zout, params);
        }

        for (JahiaSite jahiaSite : sites) {
            anEntry = new ZipEntry(jahiaSite.getSiteKey() + ".zip");
            zout.putNextEntry(anEntry);
            exportSite(jahiaSite, zout, params);
        }

        JCRSessionWrapper session = jcrStoreService.getSessionFactory().getCurrentUserSession();

        // export shared files -->
        Set<JCRNodeWrapper> files = new HashSet<JCRNodeWrapper>();
        try {
            files.add(session.getNode("/users"));
        } catch (RepositoryException e) {
            e.printStackTrace();
            throw new IOException(e.getMessage());
        }

        zout.putNextEntry(new ZipEntry("users.zip"));
        ZipOutputStream zzout = new ZipOutputStream(zout);
        Set<String> tti = new HashSet<String>();
        tti.add(Constants.JAHIANT_VIRTUALSITE);
        try {
            exportNodesWithBinaries(session.getRootNode(), files, zzout, tti, params);
        } catch (Exception e) {
            e.printStackTrace()//To change body of catch statement use File | Settings | File Templates.
        }
        zzout.finish();
        zout.finish();
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.