Package java.util.zip

Examples of java.util.zip.ZipOutputStream


        String exportFileName = page.getExportFileName();

        try
        {
            // Creating the ZipOutputStream
            ZipOutputStream zos = new ZipOutputStream( new FileOutputStream( new File( exportFileName ) ) );
            // Writing the Connections file.
            zos.putNextEntry( new ZipEntry( Messages.getString( "ExportConnectionsWizard.1" ) ) ); //$NON-NLS-1$
            Connection[] connections = ConnectionCorePlugin.getDefault().getConnectionManager().getConnections();
            Set<ConnectionParameter> connectionParameters = new HashSet<ConnectionParameter>();
            for ( Connection connection : connections )
            {
                connectionParameters.add( connection.getConnectionParameter() );
            }
            ConnectionIO.save( connectionParameters, zos );
            zos.closeEntry();
            // Writing the Connection Folders file.
            zos.putNextEntry( new ZipEntry( Messages.getString( "ExportConnectionsWizard.2" ) ) ); //$NON-NLS-1$
            ConnectionFolder[] connectionFolders = ConnectionCorePlugin.getDefault().getConnectionFolderManager()
                .getConnectionFolders();
            Set<ConnectionFolder> connectionFoldersSet = new HashSet<ConnectionFolder>();
            for ( ConnectionFolder connectionFolder : connectionFolders )
            {
                connectionFoldersSet.add( connectionFolder );
            }
            ConnectionIO.saveConnectionFolders( connectionFoldersSet, zos );
            zos.closeEntry();
            // Writing the Browser Connections file.
            zos.putNextEntry( new ZipEntry( Messages.getString( "ExportConnectionsWizard.3" ) ) ); //$NON-NLS-1$
            IBrowserConnection[] browserConnections = BrowserCorePlugin.getDefault().getConnectionManager()
                .getBrowserConnections();
            Map<String, IBrowserConnection> browserConnectionsMap = new HashMap<String, IBrowserConnection>();
            for ( IBrowserConnection browserConnection : browserConnections )
            {
                browserConnectionsMap.put( browserConnection.getConnection().getId(), browserConnection );
            }
            BrowserConnectionIO.save( zos, browserConnectionsMap );
            zos.closeEntry();
            // Closing the ZipOutputStream
            zos.close();
        }
        catch ( FileNotFoundException e )
        {
            // TODO Auto-generated catch block
            e.printStackTrace();
View Full Code Here


            try {
                input = new FileInputStream(this.logFile);
                output = resp.getOutputStream();

                if (req.getRequestURI().endsWith(ZIP_FILE_MARKER)) {
                    ZipOutputStream zip = new ZipOutputStream(output);
                    zip.setLevel(Deflater.BEST_SPEED);

                    ZipEntry entry = new ZipEntry(this.logFile.getName());
                    entry.setTime(this.logFile.lastModified());
                    entry.setMethod(ZipEntry.DEFLATED);

                    zip.putNextEntry(entry);

                    output = zip;
                    resp.setContentType("application/zip");
                } else {
                    resp.setContentType("text/plain");
View Full Code Here

    private void dumpRepository(String[] bundleNames, HttpServletResponse resp) throws IOException {

        Set selectedBundles = this.getSelectedBundles(bundleNames);

        resp.setContentType("application/zip");
        ZipOutputStream jos = null;
        try {
            jos = new ZipOutputStream(resp.getOutputStream());

            // spool the repository.xml
            ZipEntry entry = new ZipEntry("repository.xml");
            jos.putNextEntry(entry);
            PrintWriter pw = new PrintWriter(new OutputStreamWriter(jos, "UTF-8"));
            this.printRepositoryXML(pw, "", selectedBundles);
            pw.flush();
            jos.closeEntry();

            for (Iterator ri = this.repository.getResourcesById(); ri.hasNext();) {
                Resource res = (Resource) ri.next();

                // spool the resource out if selected or global dump
                String resourceName = res.getResourceName();
                if (selectedBundles == null
                        || selectedBundles.contains(resourceName)) {
                    entry = new ZipEntry(resourceName);
                    jos.putNextEntry(entry);
                    res.spool(jos);
                    jos.closeEntry();
                }
            }

        } finally {
            IOUtils.closeQuietly(jos);
View Full Code Here

        return file;
    }

    public static File createZipFileInTemporaryFolder(File targetFolder, String name, File content) throws IOException {
        File file = new File(targetFolder, name);
        ZipOutputStream zipOutputStream = new ZipOutputStream(new FileOutputStream(file));
        zipOutputStream.putNextEntry(new ZipEntry(content.getName()));
        zipOutputStream.write(FileUtils.readFileToByteArray(content));
        zipOutputStream.closeEntry();
        zipOutputStream.close();
        file.deleteOnExit();
        return file;
    }
View Full Code Here

   
    private ZipOutputStream createOutputStream() throws CoreException
    {
        try
        {
            return new ZipOutputStream(new FileOutputStream(archiveFile));
        }
        catch (FileNotFoundException e)
        {
            throw new CoreException(new Status(
                IStatus.ERROR,
View Full Code Here

        RubyHash hash = (RubyHash) entries;
        try {
            FileOutputStream file = newFile(jar_path);
            try {
                ZipOutputStream zip = new ZipOutputStream(file);
                addEntries(context, zip, hash);
                zip.finish();
            } finally {
                close(file);
            }
        } catch (IOException e) {
            if (runtime.isDebug()) {
View Full Code Here

    monitor = ProgressUtil.getMonitorFor(monitor);

    try {
      BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(tempFile));
      ZipOutputStream zout = new ZipOutputStream(bout);
      addZipEntries(zout, allResources, filterInFiles);
      zout.close();

    }
    catch (CoreException e) {
      return new IStatus[] { e.getStatus() };
    }
View Full Code Here

    public ZipDataSource(String name, InputStream in) throws IOException {
        this.name = name + FILE_EXTENSION;

        ByteArrayOutputStream baos = new ByteArrayOutputStream();
        ZipOutputStream zos = new ZipOutputStream(baos);
        zos.putNextEntry(new ZipEntry(name));

        int size;
        byte[] buffer = new byte[BUFFER_SIZE];
        while ((size = in.read(buffer, 0, buffer.length)) > 0) {
            zos.write(buffer, 0, size);
        }
        zos.closeEntry();
        zos.close();
        in.close();
        contents = baos.toByteArray();
    }
View Full Code Here

      {
    //create object of FileOutputStream
    FileOutputStream fout = new FileOutputStream(zipFile);
                                
    //create object of ZipOutputStream from FileOutputStream
    ZipOutputStream zout = new ZipOutputStream(fout);
                      
    //create File object from source directory
    File fileSource = new File(sourceDir);
                      
    FileUtils.addDirectory(zout, fileSource);
                      
    //close the ZipOutputStream
    zout.close();
                      
    System.out.println("Zip file has been created!");
                      
      }
  catch(IOException ioe)
View Full Code Here

      try{
    //create object of FileOutputStream
    FileOutputStream fout = new FileOutputStream(zipFile);
                                        
    //create object of ZipOutputStream from FileOutputStream
    ZipOutputStream zout = new ZipOutputStream(fout);
                              
    com.rackspace.cloud.api.docs.FileUtils.addDirectory(zout, sourceDir);
                              
    //close the ZipOutputStream
    zout.close();
                                                             
      }catch(IOException ioe){
    System.out.println("IOException :" + ioe);    
      }
  }
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.