Examples of ZipOutputStream


Examples of java.util.zip.ZipOutputStream

        this.archiveFile = archiveFile;
    }

    public void doArchive() throws Exception {
        FileOutputStream stream = new FileOutputStream(archiveFile);
        ZipOutputStream output = new ZipOutputStream(stream);
        compressFile(folderToArchive, output);
        output.close();
        stream.close();
    }
View Full Code Here

Examples of java.util.zip.ZipOutputStream

        }
        try {
            String name = db.getName();
            name = IOUtils.getFileName(name);
            OutputStream zip = IOUtils.openFileOutputStream(fileName, false);
            ZipOutputStream out = new ZipOutputStream(zip);
            db.flush();
            String fn = db.getName() + Constants.SUFFIX_PAGE_FILE;
            backupPageStore(out, fn, db.getPageStore());
            // synchronize on the database, to avoid concurrent temp file
            // creation / deletion / backup
            String base = IOUtils.getParent(fn);
            synchronized (db.getLobSyncObject()) {
                String prefix = db.getDatabasePath();
                String dir = IOUtils.getParent(prefix);
                dir = FileLister.getDir(dir);
                ArrayList<String> fileList = FileLister.getDatabaseFiles(dir, name, true);
                for (String n : fileList) {
                    if (n.endsWith(Constants.SUFFIX_LOB_FILE)) {
                        backupFile(out, base, n);
                    }
                }
            }
            out.close();
            zip.close();
        } catch (IOException e) {
            throw DbException.convertIOException(e, fileName);
        }
    }
View Full Code Here

Examples of java.util.zip.ZipOutputStream

  }
  public static final int BUFFER = 4096;
  public static void speedupZip(InputStream input, OutputStream output)
    throws IOException {
    ZipInputStream in = new ZipInputStream(input);
    ZipOutputStream out = new ZipOutputStream(output);
    ZipEntry inentry;
    ZipEntry outentry;
    int count;
    byte[] buffer = new byte[BUFFER];
    while ((inentry = in.getNextEntry()) != null) {
      outentry = new ZipEntry(inentry.getName());
      logger.debug("Extra: " + inentry.getExtra());
      outentry.setExtra(inentry.getExtra());
      logger.debug("time: " + inentry.getTime());
      outentry.setTime(inentry.getTime());
      logger.debug("method: " + inentry.getMethod());
      outentry.setMethod(inentry.getMethod());
      logger.debug("comment: " + inentry.getComment());
      outentry.setComment(inentry.getComment());
      logger.debug("CRC: " + inentry.getCrc());
      if (inentry.getCrc() != -1) {
        outentry.setCrc(inentry.getCrc());
      }
      logger.debug("size: " + inentry.getSize());
      if (inentry.getSize() != -1) {
        outentry.setSize(inentry.getSize());
      }
      out.putNextEntry(outentry);
      if (!inentry.isDirectory()) {
        if (inentry.getName().endsWith(".jar")
          || inentry.getName().endsWith(".zip")
          || inentry.getName().endsWith(".war")
          || inentry.getName().endsWith(".ear")) {
          speedupZip(in, out);
        } else if (inentry.getName().endsWith(".class")) {
          speedup(in, inentry.getName(), out);
        } else {
          while ((count = in.read(buffer, 0, BUFFER)) != -1) {
            out.write(buffer, 0, count);
          }
        }

      }
      out.closeEntry();
      in.closeEntry();
    }
    out.close();
    in.close();
  }
View Full Code Here

Examples of java.util.zip.ZipOutputStream

        outFile.delete();
      }

      AEDiagnostics.flushPendingLogs();

      ZipOutputStream out = new ZipOutputStream(new FileOutputStream(outFile));

      // %USERDIR%\logs
      File logPath = new File(SystemProperties.getUserPath(), "logs");
      File[] files = logPath.listFiles(new FileFilter() {
        public boolean accept(File pathname) {
          return pathname.getName().endsWith(".log");
        }
      });
      addFilesToZip(out, files);

      // %USERDIR%
      File userPath = new File(SystemProperties.getUserPath());
      files = userPath.listFiles(new FileFilter() {
        public boolean accept(File pathname) {
          return pathname.getName().endsWith(".log");
        }
      });
      addFilesToZip(out, files);

      // %USERDIR%\debug
      files = path.listFiles();
      addFilesToZip(out, files);

      // recent errors from exe dir
      final long ago = SystemTime.getCurrentTime() - 1000L * 60 * 60 * 24 * 90;
      File azureusPath = new File(SystemProperties.getApplicationPath());
      files = azureusPath.listFiles(new FileFilter() {
        public boolean accept(File pathname) {
          return (pathname.getName().startsWith("hs_err") && pathname.lastModified() > ago);
        }
      });
      addFilesToZip(out, files);

      // recent errors from OSX java log dir
      File javaLogPath = new File(System.getProperty("user.home"), "Library"
          + File.separator + "Logs" + File.separator + "Java");
      if (javaLogPath.isDirectory()) {
        files = javaLogPath.listFiles(new FileFilter() {
          public boolean accept(File pathname) {
            return (pathname.getName().endsWith("log") && pathname.lastModified() > ago);
          }
        });
        addFilesToZip(out, files);
      }

      // recent OSX crashes
      File diagReportspath = new File(System.getProperty("user.home"), "Library"
          + File.separator + "Logs" + File.separator + "DiagnosticReports");
      if (diagReportspath.isDirectory()) {
        files = diagReportspath.listFiles(new FileFilter() {
          public boolean accept(File pathname) {
            return (pathname.getName().endsWith("crash") && pathname.lastModified() > ago);
          }
        });
        addFilesToZip(out, files);
      }

      boolean bLogToFile = COConfigurationManager.getBooleanParameter("Logging Enable");
      String sLogDir = COConfigurationManager.getStringParameter("Logging Dir",
          "");
      if (bLogToFile && sLogDir != null) {
        File loggingFile = new File(sLogDir, FileLogging.LOG_FILE_NAME);
        if (loggingFile.isFile()) {
          addFilesToZip(out, new File[] {
            loggingFile
          });
        }
      }

      if (extraLogDirs != null) {
        for (File file : extraLogDirs) {
          files = file.listFiles(new FileFilter() {
            public boolean accept(File pathname) {
              return pathname.getName().endsWith("stackdump")
                  || pathname.getName().endsWith("log");
            }
          });
          addFilesToZip(out, files);
        }
      }

      out.close();

      if (outFile.exists()) {
        gr.file = outFile;
        return gr;
      }
View Full Code Here

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

Examples of java.util.zip.ZipOutputStream

        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

Examples of java.util.zip.ZipOutputStream

  }

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

Examples of java.util.zip.ZipOutputStream

    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

Examples of java.util.zip.ZipOutputStream

        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

Examples of java.util.zip.ZipOutputStream

     * @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
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.