Package java.util.jar

Examples of java.util.jar.JarFile$JarEntryFactory


  }
 
  private void executeUnzip() throws Exception {
   
    File file = null;
    JarFile jar;
    Enumeration content;
    JarEntry entry;
    String classFile = "";
    String filename = "";
    long archiveDate;
    long hdDate;
    int extracted = 0;
    int processed = 0;
   
    // individuelle Manifest Sektionen
    ArrayList iSecName = new ArrayList();
    ArrayList iSecOrigin = new ArrayList();
    ArrayList iSecDate = new ArrayList();
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
    String jarDate;
    int index;
   
    // Verzeichnis der Archive einlesen
    file = new File( this.source );
   
    // alle zu durchsuchenden jar- und zip-Archive ermitteln
    String path = null;
    String[] list = null;
   
    if ( file.isDirectory() ) {
      path = this.source;
      list = this.archiveFilter(file.list());
    } else {
      path = file.getPath().substring(0,file.getPath().length()-file.getName().length());
      list = new String[1];
      list[0] = file.getName();
    }
   
    if ( list.length == 0 ) {
      this.logln("\n no jar/zip archives found");
      return;
    }
   
    if ( this.oldOverwrites )
      this.logln("\n directive: overwrite newer versions");
    else
      this.logln("\n directive: overwrite older versions");
   
    try {
     
      // alle Archive durchgehen
      for (int i=0; i<list.length; i++) {
       
        this.logln("\n unpack "+ list[i] +":");
       
        jar = new JarFile(path + list[i]);
        content = jar.entries();
       
        file = new File(path + list[i]);
        jarDate = ( file.lastModified() < 0 ) ? "unknown" : sdf.format(new Date(file.lastModified()))
       
        // alle Klassen eines Archivs durchgehen
View Full Code Here


    if ( jarFile==null ) throw new Exception("jarFile is null");
    if ( tobeJared==null ) throw new Exception("array of files is null");
    if ( tobeJared.length==0 ) throw new Exception("no files to archive");
   
  // Inhalt des bestehenden jars auslesen
    JarFile jar = new JarFile(jarFile);
    Enumeration jarEnum = jar.entries();
    Hashtable jarContent = new Hashtable();
   
    String elem;
    // alle Dateien eines Archivs durchgehen
    while ( jarEnum.hasMoreElements() ) {
      elem = ((JarEntry)jarEnum.nextElement()).getName();
      jarContent.put(elem, "notnull");
    }
   
    // JarFile schliessen
    jar.close();
   
  // Manifest ermitteln
    Manifest manifest = readManifestFile(manifestFile);
    if ( manifest!=null ) {
      File file = new File(manifestFile);
View Full Code Here

  }

  public static String autoDetectPackageName(File file) {
    try {
      Set<String> packageNames = new HashSet<String>();
      JarFile jarFile = new JarFile(file);
      Enumeration<JarEntry> entries = jarFile.entries();
      while (entries.hasMoreElements()) {
        JarEntry entry = entries.nextElement();
        String name = entry.getName();
        if (name.endsWith(".class")) {
          logger.debug("Considering package of entry '{}'", name);
View Full Code Here

      } else {
        // No version in file name, just remove the ".jar"-suffix
        bn = fileName.substring(0, fileName.length() - 4);
      }

      final JarFile bundle = new JarFile(file);
      try {
        final Manifest manifest = bundle.getManifest();
        this.mainAttributes = manifest.getMainAttributes();
        this.manifestVersion = deriveBundleManifestVersion();
        this.bsn = deriveBundleSymbolicName();
        this.version = deriveBundleVersion();
        this.name = mainAttributes.getValue(Constants.BUNDLE_NAME);

        int count = 0;
        for (Enumeration e = bundle.entries(); e.hasMoreElements();) {
          ZipEntry entry = (ZipEntry) e.nextElement();

          if (entry.getName().startsWith(SRC_PREFIX)) {
            count++;
          }
        }
        srcCount = count;

      } finally {
        if (null != bundle) {
          try {
            bundle.close();
          } catch (IOException _ioe) {
          }
        }
      }
View Full Code Here

     *         path relative to <code>destDir</code>.
     * @throws IOException
     */
    public List extractSources(File destDir) throws IOException {
      final List res = new ArrayList();
      final JarFile jarFile = new JarFile(file);
      for (Enumeration e = jarFile.entries(); e.hasMoreElements();) {
        ZipEntry entry = (ZipEntry) e.nextElement();

        if (entry.getName().startsWith(SRC_PREFIX)) {
          if (0 == res.size()) {
            destDir.mkdirs();
View Full Code Here

      this.file = file;
      path = Util.replace(file.getCanonicalPath().substring(1 + baseDir.getCanonicalPath().length()), "\\", "/");
    }

    public void load() throws Exception {
      JarFile    jarFile      = new JarFile(file);
      Manifest   mf           = jarFile.getManifest();
      attribs                 = mf.getMainAttributes();

      pkgExportMap     = parseNames(attribs.getValue("Export-Package"));
      pkgImportMap     = parseNames(attribs.getValue("Import-Package"));
View Full Code Here

            } else if ("jar".equals(url.getProtocol())) {

                JarURLConnection conn = (JarURLConnection) url.openConnection();

                JarFile jar = conn.getJarFile();

                Enumeration<JarEntry> en = jar.entries();

                while (en.hasMoreElements()) {
                    JarEntry jarEntry = en.nextElement();

                    String classname = jarEntry.getName();
View Full Code Here

              }
              copyInputStreamToFile(connection.getInputStream(), cachedFile);
            }
            if (extensionJarOrDllFile.endsWith(".jar")) {
              // Add tmp file to extension jars list
              extensionJars.add(new JarFile(cachedFile.toString(), false));
            } else if (extensionJarOrDllFile.endsWith(dllSuffix)) {
              // Add tmp file to extension DLLs map
              this.extensionDlls.put(extensionJarOrDllFileName.substring(extensionPrefix.length(),
                  extensionJarOrDllFileName.indexOf(dllSuffix)), cachedFile.toString());
            }
            continue;
          } catch (IOException ex) {
            // Try without cache
          }         
        }
       
        if (connection == null) {
          connection = extensionJarOrDllUrl.openConnection();
        }
        InputStream input = connection.getInputStream();         
        if (extensionJarOrDllFile.endsWith(".jar")) {
          // Copy jar to a tmp file
          String extensionJar = copyInputStreamToTmpFile(input, ".jar");
          // Add tmp file to extension jars list
          extensionJars.add(new JarFile(extensionJar, false));
        } else if (extensionJarOrDllFile.endsWith(dllSuffix)) {
          // Copy DLL to a tmp file
          String extensionDll = copyInputStreamToTmpFile(input, dllSuffix);
          // Add tmp file to extension DLLs map
          this.extensionDlls.put(extensionJarOrDllFileName.substring(extensionPrefix.length(),
View Full Code Here

    String classFile = name.replace('.', '/') + ".class";
    InputStream classInputStream = null;
    if (this.extensionJars != null) {
      // Check if searched class is an extension class
      for (int i = 0; i < this.extensionJars.length; i++) {
        JarFile extensionJar = this.extensionJars [i];
        JarEntry jarEntry = extensionJar.getJarEntry(classFile);
        if (jarEntry != null) {
          try {
            classInputStream = extensionJar.getInputStream(jarEntry);
          } catch (IOException ex) {
            throw new ClassNotFoundException("Couldn't read class " + name, ex);
          }
        }
      }
View Full Code Here

   */
  protected URL findResource(String name) {
    if (this.extensionJars != null) {
      // Try to find if resource belongs to one of the extracted jars
      for (int i = 0; i < this.extensionJars.length; i++) {
        JarFile extensionJar = this.extensionJars [i];
        JarEntry jarEntry = extensionJar.getJarEntry(name);
        if (jarEntry != null) {
          try {
            return new URL("jar:file:" + extensionJar.getName() + ":" + jarEntry.getName());
          } catch (MalformedURLException ex) {
            // Forget that we could have found a resource
          }
        }
      }
View Full Code Here

TOP

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

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.