Package java.util.jar

Examples of java.util.jar.JarEntry


          // System.out.println("jar: " + jar.getAbsolutePath());
          JarFile jarFile = new JarFile(jar);
          Enumeration entries = jarFile.entries();
          ArrayList list = new ArrayList(250);
          while (entries.hasMoreElements()) {
            JarEntry jarEntry = (JarEntry) entries.nextElement();
            if (jarEntry.getName().startsWith(bundleFolder)
                && jarEntry.getName().endsWith(extension)) {
              // System.out.println("jarEntry: " + jarEntry.getName());
              list.add(jarEntry.getName().substring(
                  bundleFolder.length() - prefix.length()));
              // "MessagesBundle_de_DE.properties"
            }
          }
          bundles = (String[]) list.toArray(new String[list.size()]);
View Full Code Here


                conn.setUseCaches(false);
            }
            jarFile = conn.getJarFile();
            Enumeration entries = jarFile.entries();
            while (entries.hasMoreElements()) {
                JarEntry entry = (JarEntry) entries.nextElement();
                String name = entry.getName();
                if (!name.startsWith("META-INF/")) continue;
                if (!name.endsWith(".tld")) continue;
                InputStream stream = jarFile.getInputStream(entry);
                try {
                    String uri = getUriFromTld(resourcePath, stream);
View Full Code Here

        packageName = packageName.replaceAll("\\.", "/");
        JarInputStream jarIn = null;
        try {           
            jarIn = new JarInputStream(new FileInputStream(jar));
            JarEntry jarEntry = jarIn.getNextJarEntry();
            while (jarEntry != null) {
                if (jarEntry.getName().endsWith(".class")) {
                    String name = jarEntry.getName().replaceAll("/", "\\.");
                    if (!name.contains("$")) {                       
                        name = name.substring(0, name.length() - ".class".length());
                    }
                    if (includeSubPackages) {
                        if (jarEntry.getName().startsWith(packageName)) {
                            classes.add(name);
                        }
                    } else {
                        if (jarEntry.getName().substring(0, jarEntry.getName().lastIndexOf('/')).equals(packageName)) {
                            classes.add(name);
                        }
                    }
                }
                jarEntry = jarIn.getNextJarEntry();
View Full Code Here

        List<File> jarFiles = retrieveJarFilesInClasspath(true);       
        for (File jarFile : jarFiles) {
            JarInputStream jarIn = null;
            try {
                jarIn = new JarInputStream(new FileInputStream(jarFile));
                JarEntry jarEntry = jarIn.getNextJarEntry();
                while (jarEntry != null) {
                    if (!jarEntry.isDirectory() && !jarEntry.getName().contains("$") && (jarEntry.getName().endsWith(".class") || jarEntry.getName().endsWith(".java"))) {
                        String packageName = jarEntry.getName().substring(0, jarEntry.getName().lastIndexOf("/"));
                        packageName = packageName.replaceAll("/", "\\.");
                       
                        String className = jarEntry.getName().replaceAll("/", "\\.");
                        if (className.endsWith(".class")) {
                            className = className.substring(0, className.indexOf(".class"));
                        } else if (className.endsWith(".java")) {
                            className = className.substring(0, className.indexOf(".java"));
                        }
View Full Code Here

      totalSizeExtract = 0;
      int jarNum = i - (urlList.length - nativeJarCount); // used for progressbar
   
      // calculate the size of the files to extract for progress bar
      while (entities.hasMoreElements()) {
        JarEntry entry = (JarEntry) entities.nextElement();
 
        // skip directories and anything in directories
        // conveniently ignores the manifest
        if (entry.isDirectory() || entry.getName().indexOf('/') != -1) {
          continue;
        }
        totalSizeExtract += entry.getSize();
      }
 
      currentSizeExtract = 0;
 
      // reset point to begining by getting list of file again
      entities = jarFile.entries();
 
      // extract all files from the jar
      while (entities.hasMoreElements()) {
        JarEntry entry = (JarEntry) entities.nextElement();
 
        // skip directories and anything in directories
        // conveniently ignores the manifest
        if (entry.isDirectory() || entry.getName().indexOf('/') != -1) {
          continue;
        }
 
        // check if native file already exists if so delete it to make room for new one
        // useful when using the reload button on the browser
        File f = new File(path + "natives" + File.separator + entry.getName());
        if (f.exists()) {
          if (!f.delete()) {
            continue; // unable to delete file, it is in use, skip extracting it
          }
        }
 
        debug_sleep(1000);
 
        InputStream in = jarFile.getInputStream(jarFile.getEntry(entry.getName()));
        OutputStream out = new FileOutputStream(path + "natives" + File.separator + entry.getName());
 
        int bufferSize;
        byte buffer[] = new byte[65536];
 
        while ((bufferSize = in.read(buffer, 0, buffer.length)) != -1) {
          debug_sleep(10);
          out.write(buffer, 0, bufferSize);
          currentSizeExtract += bufferSize;
 
          // update progress bar
          percentage = 65 + (int)(percentageParts * (jarNum + currentSizeExtract/(float)totalSizeExtract));
          subtaskMessage = "Extracting: " + entry.getName() + " " + ((currentSizeExtract * 100) / totalSizeExtract) + "%";
        }
 
        // validate if the certificate for native file is correct
        validateCertificateChain(certificate, entry.getCertificates());
 
        in.close();
        out.close();
      }
      subtaskMessage = "";
View Full Code Here

                    return;
                }
                dir.mkdir();
                manager.getLog().debug("Extracting component: " + componentName);
                for (Enumeration e=zipFile.entries(); e.hasMoreElements(); ) {
                    JarEntry entry = (JarEntry)e.nextElement();
                    File entryFile = new File(dir, entry.getName());
                    // Ignore any manifest.mf entries.
                    if (entry.getName().toLowerCase().endsWith("manifest.mf")) {
                        continue;
                    }
                    if (!entry.isDirectory()) {
                        entryFile.getParentFile().mkdirs();
                        FileOutputStream out = new FileOutputStream(entryFile);
                        InputStream zin = zipFile.getInputStream(entry);
                        byte [] b = new byte[512];
                        int len = 0;
View Full Code Here

    String packagePath = nameToPath(packageName) + "/";
    try {
      jarFile = new JarFile(file);
      Enumeration<JarEntry> en = jarFile.entries();
      while (en.hasMoreElements()) {
        JarEntry je = en.nextElement();
        String name = je.getName();
        if (name.startsWith(packagePath) && name.endsWith(CLASS_FILE)) {
          String className = name.substring(0, name.length() - CLASS_FILE.length());
          try {
            Class<?> clz = Class.forName(pathToName(className));
            results.add(clz);
View Full Code Here

        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


  protected static void searchJar(Class theClass, JarFile j, Vector results) throws IOException {
    Enumeration e = j.entries();
    while (e.hasMoreElements()) {
      JarEntry je =(JarEntry)e.nextElement();
      if (je.isDirectory()) continue;
      String entry = je.getName();
      if (!entry.endsWith(".class")) continue;
      entry = entry.substring(0,entry.length()-6); // removes .class
      entry = entry.replace('\\','/');
      entry = entry.replace('/','.');
      testElement(theClass, entry,results);
View Full Code Here

                        // 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
                        Iterator it2 = jarEntries.iterator();
                        JarEntry jarEntry;
                        while(it2.hasNext()){
                            jarEntry = (JarEntry)it2.next();
                            try{
                                extractAndCopyJarEntry(jarFile, jarEntry);
                            } catch(IOException e) {
View Full Code Here

TOP

Related Classes of java.util.jar.JarEntry

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.