Package java.util.zip

Examples of java.util.zip.ZipFile$Window


    private static ZipInfoProperties checkFile(String filename)
    {
        // try to create a ZipFile from it
        try
        {
            ZipFile zf = new ZipFile(filename);
            // try to get a ZipEntry from the ZipFile

            ZipEntry thisEntry = null;

            for (int i =0; i < infoNames.length; i++)
            {
                thisEntry = zf.getEntry(infoNames[i]);
                if (thisEntry != null)
                {
                    break;
                }
            }

            if (thisEntry == null)
            {
                return null;
            }

            InputStream bis = zf.getInputStream(thisEntry);
            if (bis == null)
            {
                return null;
            }
View Full Code Here


          if (transletTimestamp < xslTimestamp)
              return null;
      }
     
        // Create a ZipFile object for the jar file
        ZipFile jarFile = null;
        try {
            jarFile = new ZipFile(file);
        }
        catch (IOException e) {
            return null;
        }
     
        String transletPath = fullClassName.replace('.', '/');
        String transletAuxPrefix = transletPath + "$";
        String transletFullName = transletPath + ".class";
     
        Vector bytecodes = new Vector();     
     
        // Iterate through all entries in the jar file to find the
        // translet and auxiliary classes.
        Enumeration entries = jarFile.entries();
        while (entries.hasMoreElements())
        {
            ZipEntry entry = (ZipEntry)entries.nextElement();
            String entryName = entry.getName();
            if (entry.getSize() > 0 &&
                (entryName.equals(transletFullName) ||
                  (entryName.endsWith(".class") &&
                      entryName.startsWith(transletAuxPrefix))))
            {
              try {
                    InputStream input = jarFile.getInputStream(entry);
                    int size = (int)entry.getSize();
                    byte[] bytes = new byte[size];
                    readFromInputStream(bytes, input, size);
                    input.close();
                    bytecodes.addElement(bytes);
View Full Code Here

    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

TOP

Related Classes of java.util.zip.ZipFile$Window

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.