Package java.util.jar

Examples of java.util.jar.JarFile$MyJarEntry


    }

    public Manifest getManifest() {
        assertIsFile();
        try {
            JarFile jarFile = new JarFile(this);
            try {
                return jarFile.getManifest();
            } finally {
                jarFile.close();
            }
        } catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }
View Full Code Here


                + jarFileName);
        if (jarFile != null)
            jarFile.close();
        jarFile = null;

        jarFile = new JarFile(URLDecoder.decode(jarFileName, "UTF-8"));
        JarEntry entry = jarFile.getJarEntry(jarEntryName);
        inputStream = jarFile.getInputStream(entry);
        if (inputStream == null) {
            Debug.error("JarInputReader: Problem getting input stream for "
                    + jarEntryName + " in " + jarFileName);
View Full Code Here

  public static Vector search(String dirOrJar, Vector entries) {
    return search(Plugin.class, dirOrJar, entries);
  }
 
  public static Vector search(Class theClass, String dirOrJar, Vector entries) {
    JarFile j;
    if (dirOrJar.endsWith(".jar") || dirOrJar.endsWith("jsynoptic") || dirOrJar.endsWith("jsynoptic.exe")) {
      try {
        j = new JarFile(dirOrJar);
      } catch (IOException e) {
        j = null;
      }
    } else j=null;
   
    if (j!=null) {
      try {
        searchJar(theClass,j,entries);
        j.close();
      } catch (IOException e) {
      }
    }
    else searchFile(theClass,new File(dirOrJar),entries,"");
    return entries;
View Full Code Here

                } else {

                    URLConnection uc = repositoryURL.openConnection();
                    if (uc instanceof JarURLConnection){
                        JarFile  jarFile = ((JarURLConnection)uc).getJarFile();

                        // get all jar entries that belongs to the help repository
                        Set jarEntries = getJarDirectoryEntries(jarFile, ((JarURLConnection) uc).getEntryName());

                        // extract and copy the jar entries to output directory
View Full Code Here

  private void loadPrepararorJar(File file, HashMap preparatorHash,
    PreparatorSettings[] preparatorSettingsArr)
    throws RegainException
  {
    // Find the preparator classes
    JarFile jarFile = null;
    try {
      jarFile = new JarFile(file);

      // Load the manifest
      InputStream in = jarFile.getInputStream(jarFile.getEntry("META-INF/MANIFEST.MF"));
      Manifest manifest = new Manifest(in);
      in.close();

      // Read the class names
      Attributes attributes = manifest.getMainAttributes();
      String classNameCsv = attributes.getValue("Preparator-Classes");
      if (classNameCsv == null) {
        throw new RegainException("The manifest in preparator file '" + file
            + "' has no 'Preparator-Classes' attribute");
      }
      String[] classNameArr = RegainToolkit.splitString(classNameCsv, ";", true);
     
      // Load the classes if they are not disabled
      URLClassLoader loader = null;
      for (int i = 0; i < classNameArr.length; i++) {
        // Get the class name
        String className = classNameArr[i];
        if (className.startsWith(".")) {
          className = PreparatorSettings.DEFAULT_PREPARATOR_PACKAGE + className;
        }
       
        if (isPreparatorEnabled(className, preparatorSettingsArr)) {
          // Create the class loader if nessesary
          if (loader == null) {
            loader = new URLClassLoader(new URL[] { file.toURI().toURL() });
          }
         
          // Load the preparator and add it to the preparatorHash
          Preparator prep = (Preparator) RegainToolkit.createClassInstance(className, Preparator.class, loader);
          preparatorHash.put(className, prep);
        }
      }
    }
    catch (Throwable thr) {
      throw new RegainException("Loading preparator file '" + file
          + "' failed", thr);
    }
    finally {
      if (jarFile != null) {
        try { jarFile.close(); } catch (IOException exc) {}
      }
    }
  }
View Full Code Here

            } else {
                unzippedDir.mkdirs();
            }

            // Iterate through the files
            JarFile warArchive = new JarFile(warfileRef);
            for (Enumeration e = warArchive.entries(); e.hasMoreElements();) {
                JarEntry element = (JarEntry) e.nextElement();
                if (element.isDirectory()) {
                    continue;
                }
                String elemName = element.getName();

                // If archive date is newer than unzipped file, overwrite
                File outFile = new File(unzippedDir, elemName);
                if (outFile.exists() && (outFile.lastModified() > warfileRef.lastModified())) {
                    continue;
                }
                outFile.getParentFile().mkdirs();
                byte buffer[] = new byte[8192];

                // Copy out the extracted file
                InputStream inContent = warArchive.getInputStream(element);
                OutputStream outStream = new FileOutputStream(outFile);
                int readBytes = inContent.read(buffer);
                while (readBytes != -1) {
                    outStream.write(buffer, 0, readBytes);
                    readBytes = inContent.read(buffer);
View Full Code Here

    /**
     * Iterates through a jar file searching for a class. If found, it returns that classes date
     */
    private Long searchJarPath(String classResourceName, File path)
            throws IOException, InterruptedException {
        JarFile jar = new JarFile(path);
        for (Enumeration e = jar.entries(); e.hasMoreElements() && !interrupted;) {
            JarEntry entry = (JarEntry) e.nextElement();
            if (entry.getName().equals(classResourceName))
                return new Long(path.lastModified());
        }
        return null;
View Full Code Here

    protected ZipFile createZipFile(File file) throws FileSystemException
    {
        try
        {
            return new JarFile(file);
        }
        catch (IOException ioe)
        {
            throw new FileSystemException("vfs.provider.jar/open-jar-file.error", file, ioe);
        }
View Full Code Here

                    url = new URL(str);
                } catch (MalformedURLException e) {
                    return;
                }
            }
            JarFile jar;
            try {
                jar = new JarFile(url.getPath());
                Enumeration entries = jar.entries();
                while (entries.hasMoreElements()) {
                    JarEntry entry = (JarEntry)entries.nextElement();
                    if (!entry.isDirectory()
                        && !entry.getName().startsWith("META")
                        && entry.getTime() > timestamp) {
View Full Code Here

        // Unpack directory
        File unpackDir = new File(rootUnpackDir, earName + File.separator + warFile.getName());

        // Build a JarFile on the war
        JarFile packedJar;
        try {
            packedJar = new JarFile(warFile);
        } catch (IOException e) {
            throw new DeployerException("The war file '" + warFile + "' is not a valid war file", e);
        }

        // Unpack the war
View Full Code Here

TOP

Related Classes of java.util.jar.JarFile$MyJarEntry

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.