Package java.util.zip

Examples of java.util.zip.ZipFile


    private static void findClassesInOnePath(String strPath, Set<String> listClasses) throws IOException {
        File file = new File(strPath);
        if (file.isDirectory()) {
            findClassesInPathsDir(strPath, file, listClasses);
        } else if (file.exists()) {
            ZipFile zipFile = null;
            try {
                zipFile = new ZipFile(file);
                Enumeration<? extends ZipEntry> entries = zipFile.entries();
                while (entries.hasMoreElements()) {
                    String strEntry = entries.nextElement().toString();
                    if (strEntry.endsWith(DOT_CLASS)) {
                        listClasses.add(fixClassName(strEntry));
                    }
                }
            } catch (IOException e) {
                log.warn("Can not open the jar " + strPath + " " + e.getLocalizedMessage(),e);
            }
            finally {
                if(zipFile != null) {
                    try {zipFile.close();} catch (Exception e) {}
                }
            }
        }
    }
View Full Code Here


        }
        return null;
    }
    private void injectData(File zipfile, OutputStream out) throws IOException
    {
        ZipFile zip = new ZipFile(zipfile);

        ZipOutputStream zos = new ZipOutputStream(out);

        @SuppressWarnings("unchecked")
        Enumeration<ZipEntry> en = (Enumeration<ZipEntry>) zip.entries();
        while (en.hasMoreElements())
        {
            ZipEntry ze = en.nextElement();
            zos.putNextEntry(new ZipEntry(ze.getName()));
            InputStream is = zip.getInputStream(ze);
            XSSFSheet xSheet=getSheetFromZipEntryName(ze.getName());
            if(xSheet!=null)
            {
                SXSSFSheet sxSheet=getSXSSFSheet(xSheet);
                copyStreamAndInjectWorksheet(is,zos,sxSheet.getWorksheetXMLInputStream());
View Full Code Here

        }
        if (!source.exists() || !source.canRead() || source.isDirectory()) {
            throw new IllegalArgumentException("Cannot read source file at " + source.getAbsolutePath());
        }
        int size = 0;
        ZipFile zip = null;
        try {
            zip = new ZipFile(source);
            for (Enumeration entries=zip.entries(); entries.hasMoreElements();) {
              ZipEntry entry = (ZipEntry)entries.nextElement();
              size += entry.getSize();
            }
        } catch (ZipException ze) {
            size = (int)source.length();
        } finally {
            if (zip != null) {
                zip.close();
            }
        }
        FileInputStream is = new FileInputStream(source);
        try {
            copyToRepository(is, size, destination, monitor);
View Full Code Here

        unpack(targetDir, packedConfigurationDir);
        return targetDir;
    }
   
    public void unpack(File targetDir, File packedConfigurationDir) throws IOException {
        ZipFile zipFile = new ZipFile(packedConfigurationDir);
        Enumeration<? extends ZipEntry> zipEntries = zipFile.entries();
        while (zipEntries.hasMoreElements()) {
            ZipEntry zipEntry = zipEntries.nextElement();
            File targetFile = new File(targetDir, zipEntry.getName());

            if (zipEntry.isDirectory()) {
                targetFile.mkdirs();
            } else {
                targetFile.getParentFile().mkdirs();
                targetFile.createNewFile();
                OutputStream out = new FileOutputStream(targetFile);
                out = new BufferedOutputStream(out);
                InputStream in = zipFile.getInputStream(zipEntry);

                byte[] buffer = new byte[1024];
                int read;
                while (-1 != (read = in.read(buffer))) {
                    out.write(buffer, 0, read);
View Full Code Here

    }

    if (logger.isInfoEnabled())
      logger.info("Installing " + file);

    ZipFile zipFile = new ZipFile(file);

        byte[] buffer = new byte[5 * 1024];
        Enumeration<ZipEntry> entries = (Enumeration<ZipEntry>) zipFile.entries();
    while (entries.hasMoreElements()) {
      ZipEntry entry = entries.nextElement();

            String repoEntryName = getRepoEntryName(entry);
      if (repoEntryName != null) {
                File extract = extract(zipFile, buffer, entry, repoEntryName, localRepoPath);
                if (isFeaturesRepository(extract)) {
                    addToFeaturesRepositories(repoEntryName);
                }
      }
            if (entry.getName().startsWith("resource")) {
                String resourceEntryName = entry.getName().substring("resource/".length());
                extract(zipFile, buffer, entry, resourceEntryName, base);

            }
    }

    zipFile.close();

    updateTimestamp(file);
  }
View Full Code Here

    // Otherwise, check to see if it's a zip file containing a META-INF/KARAF.MF manifest.
    //
    else if (file.isFile() && file.getName().endsWith(ZIP_SUFFIX)) {
      logger.debug("Found a .zip file to deploy; checking contents to see if it's a Karaf archive.");
      try {
        if (new ZipFile(file).getEntry("META-INF/KARAF.MF") != null) {
          logger.info("Found a Karaf archive with .zip prefix; will deploy.");
          return true;
        }
      } catch (Exception e) {
        logger.warn("Problem extracting zip file '" + file.getName() + "'; ignoring.", e);
View Full Code Here

  /* Unzips dirName + ".zip" --> dirName, removing dirName
     first */
  public void unzip(String zipName, String destDirName) throws IOException {

    Enumeration entries;
    ZipFile zipFile;
    zipFile = new ZipFile(zipName + ".zip");

    entries = zipFile.entries();

    String dirName = fullDir(destDirName);

    File fileDir = new File(dirName);
    rmDir(destDirName);

    fileDir.mkdir();

    while (entries.hasMoreElements()) {
      ZipEntry entry = (ZipEntry) entries.nextElement();

      InputStream in = zipFile.getInputStream(entry);
      OutputStream out = new BufferedOutputStream(new FileOutputStream(new File(fileDir, entry.getName())));

      byte[] buffer = new byte[8192];
      int len;
      while((len = in.read(buffer)) >= 0) {
        out.write(buffer, 0, len);
      }

      in.close();
      out.close();
    }

    zipFile.close();
  }
View Full Code Here

    }

    private List<String> load(File jarFile) throws IOException {
        List<String> jarContents = new ArrayList<String>();
        try {
            ZipFile zf = new ZipFile(jarFile);
            for (Enumeration<? extends ZipEntry> e = zf.entries(); e.hasMoreElements();) {
                ZipEntry ze = e.nextElement();
                if (ze.isDirectory()) {
                    continue;
                }
                jarContents.add(ze.getName());
            }
            zf.close();
        } catch (NullPointerException e) {
            System.out.println("done.");
        } catch (ZipException ze) {
            ze.printStackTrace();
        }
View Full Code Here

    // This routine does not generate identifiers, as wookie would on empty <id> elements found in the config.xml.
    // NOTE: this has been fixed in wookie 0.13.0 onwards
    private Widget returnURLFromConfig(File wgtFile){
        Widget widget = null;
        try {
            final ZipFile zipFile = new ZipFile(wgtFile);
            ZipEntry entry = zipFile.getEntry("config.xml");
            InputStream input = zipFile.getInputStream(entry);
            BufferedReader br = new BufferedReader(new InputStreamReader(input, "UTF-8"));
            try {
                String line = null;
                while (( line = br.readLine()) != null){
                    if(line.contains("id=")){
View Full Code Here

        else
        {
            jarFile = getJarFile( dataDirectory);
            dataDirectory = "";
        }
        zipData = new ZipFile( jarFile);
        canonicalName = "(" + jarFile.getCanonicalPath() + ")" + dataDirectory;
        separatedDataDirectory = dataDirectory + '/'; // Zip files use '/' as a separator
        createTempDir();
    } // end of doInit
View Full Code Here

TOP

Related Classes of java.util.zip.ZipFile

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.