Package java.util.zip

Examples of java.util.zip.ZipOutputStream


        String date = format.format(cal.getTime());

        String filename = "datacrow_backup_" + date + ".bck";
        String zipFile = target.endsWith(File.separator) ? target + filename :
                                                           target + File.separator + filename;
        ZipOutputStream zout = null;
        try {
            FileOutputStream fos = new FileOutputStream(zipFile);
            zout = new ZipOutputStream(fos);
        } catch (Exception e) {
            listener.sendError(e);
        }

        return zout;
View Full Code Here


        try {
            Collection<String> files = getFiles();
            listener.notifyProcessingCount(files.size());
           
            byte b[] = new byte[512];
            ZipOutputStream zout = getZipOutputStream(directory.toString());
           
            if (zout != null) {
                ZipEntry versionEntry = new ZipEntry("version.txt");
                zout.putNextEntry(versionEntry);
                String version = String.valueOf(DataCrow.getVersion().toString());
                zout.write(version.getBytes(), 0, version.getBytes().length);
               
                if (comment.length() > 0)
                    zout.write(("\n" + comment).getBytes(), 0, ("\n" + comment).getBytes().length);
               
                zout.closeEntry();
               
                for (String file : files) {
                    if (!file.endsWith(".log")) {
                        InputStream in = new FileInputStream(file);
                        ZipEntry e = new ZipEntry(file.replace(File.separatorChar, '/'));
                        zout.putNextEntry(e);
                        int len = 0;
                        while ((len = in.read(b)) != -1) {
                            zout.write(b, 0, len);
                        }

                        listener.sendMessage(DcResources.getText("msgCreatingBackupOfFile", file));

                        in.close();
                        zout.closeEntry();
                    }

                    listener.notifyProcessed();
                }
               
                zout.close();
                listener.sendMessage(DcResources.getText("msgWritingBackupFile"));
            }
        } catch (Exception e) {
            listener.sendMessage(DcResources.getText("msgBackupError", e.getMessage()));
            listener.sendError(e);
View Full Code Here

  }

  public ZipFile(File file) throws FileNotFoundException {
    fos = new FileOutputStream(file);
        bos = new BufferedOutputStream(fos);
        zout = new ZipOutputStream(bos);
  }
View Full Code Here

    public static void zip(String zipFileName, String inputFile) throws IOException {
        zip(zipFileName, new File(inputFile));
    }

    public static void zip(String zipFileName, File inputFile) throws IOException {
        ZipOutputStream out = new ZipOutputStream(new FileOutputStream(zipFileName));
        zip(out, inputFile, "");
        out.close();
    }
View Full Code Here

        zip(out, inputFile, "");
        out.close();
    }

    public static void zip(String inputFile, OutputStream output) throws IOException {
        ZipOutputStream out = new ZipOutputStream(output);
        zip(out, new File(inputFile), "");
        out.close();
    }
View Full Code Here

     * @param zipFile
     * @return true if archive process has succeeded
     */
    protected boolean archiveSynoptics(File[] files,  File zipFile){
        boolean res = true;
        ZipOutputStream zos = null;
        try {
            zos = new ZipOutputStream(new BufferedOutputStream(new FileOutputStream(zipFile)));
            zos.setMethod(ZipOutputStream.DEFLATED);

            if (files != null){
                for(int i=0; i< files.length; i++){
                    addFileResourceToArchive(zos, files[i], files[i].getName());
               
            }

        } catch (IOException e) {
            //TODO display message
            res = false;
        }

        try {
            if (zos != null){
                zos.finish();
                zos.close();
            }
        } catch (IOException e) {
            //TODO display message
            res = false;
        }
View Full Code Here

    {
        // - retrieve the name of the file given by the path.
        final String name = path.replaceAll(
                PATH_REMOVE_PATTERN,
                "");
        final ZipOutputStream zipOutputStream = new ZipOutputStream(new java.io.FileOutputStream(modelArchive));
        final ZipEntry zipEntry = new ZipEntry(name);
        zipEntry.setMethod(ZipEntry.DEFLATED);
        zipOutputStream.putNextEntry(zipEntry);
        final java.io.FileInputStream inputStream = new java.io.FileInputStream(path);
        final byte[] buffer = new byte[1024];
        int n = 0;
        while ((n =
                inputStream.read(
                    buffer,
                    0,
                    buffer.length)) > 0)
        {
            zipOutputStream.write(
                buffer,
                0,
                n);
        }
        inputStream.close();
        zipOutputStream.closeEntry();
        zipOutputStream.close();
    }
View Full Code Here

  /**
   * Save all MEMORY tables to encrypted storage.
   */
  public void save () {
    Connection connection = null;
    ZipOutputStream zip = null;
    try {
      connection = dataSource.getConnection();
     
      IVirtualFile storage = BackupUtil.rotate(this.storageDirectory, "backup", "dat", 20);
      storage.setIOHandler( new EncryptionIOHandler(provider) );
     
      zip = new ZipOutputStream(storage.getOutputStream());
     
      PrintWriter writer = new PrintWriter(zip, true);
      for (EncryptedTable table : getEncryptedTables(connection)) {
        ZipEntry entry = new ZipEntry(table.tableName + ".dat");
        zip.putNextEntry(entry);
        table.save(connection, writer);
        writer.flush();
        zip.closeEntry();
      }
      zip.flush();
      zip.close();
    } catch (Exception e) {
      if (zip != null) {
        try {
          zip.close();
          BackupUtil.reverseRotation(this.storageDirectory, "backup", "dat", 20);
        }
        catch (Exception ee) {
          throw ThrowableManagerRegistry.caught(ee);
        }
View Full Code Here

   * @see net.sourceforge.squirrel_sql.client.update.UpdateUtil#createZipFile(FileWrapper, FileWrapper[])
   */
  public void createZipFile(FileWrapper zipFile, FileWrapper... sourceFiles) throws FileNotFoundException,
    IOException
  {
    ZipOutputStream os = new ZipOutputStream(new FileOutputStream(zipFile.getAbsolutePath()));
    zipFileOs(os, sourceFiles);
    os.close();
  }
View Full Code Here

  /**
   *
   */
  public void zipEntries(OutputStream os) throws IOException
  {
    ZipOutputStream zipos = new ZipOutputStream(os);
    zipos.setMethod(ZipOutputStream.DEFLATED);
   
    for (int i = 0; i < exportZipEntries.size(); i++)
    {
      ExportZipEntry exportZipEntry = (ExportZipEntry)exportZipEntries.get(i);
      ZipEntry zipEntry = new ZipEntry(exportZipEntry.getName());
      zipos.putNextEntry(zipEntry);
      exportZipEntry.writeData(zipos);
    }
   
    zipos.flush();
    zipos.finish();
  }
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.