Examples of JarEntry


Examples of java.util.jar.JarEntry

  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
        while ( content.hasMoreElements() ) {
         
          entry = (JarEntry)content.nextElement();
          classFile = entry.getName();
         
          if ( !(classFile.charAt(classFile.length()-1)=='/' || classFile.toUpperCase().equals("META-INF/MANIFEST.MF")) ) {
           
            index = classFile.lastIndexOf('/')+1; // behandelt R�ckgabewert -1 implizit mit
            // Dateiname muss vom regul�ren Ausdruck erfasst werden
            if ( this.fileFilterPattern.matcher(classFile.substring(index)).matches() ) {
             
              // Paketstruktur aufl�sen?
              if ( this.detach )
                filename = classFile.substring(index);
              else
                filename = classFile;
             
              file = new File( ((this.targetPath!=null) ? this.targetPath : "") + filename );
             
              // Datei existiert schon auf Platte
              if ( file.canRead() ) {
               
                hdDate = file.lastModified();
                archiveDate = entry.getTime();
               
                if ( (!this.oldOverwrites && (archiveDate > hdDate)) || (this.oldOverwrites && (archiveDate < hdDate)) ) {
                  this.unpackJarEntry(jar, entry, this.targetPath);
                 
                  // f�r Manifest individuelle Sektionen
View Full Code Here

Examples of java.util.jar.JarEntry

      JarOutputStream out = new JarOutputStream(stream, manifest);
     
      if ( this.compression != -1)
        out.setLevel(this.compression);
     
      JarEntry jarAdd;
     
      for (int i = 0; i < tobeJared.length; i++) {
       
        if ( tobeJared[i] == null )
          continue;
        if ( !tobeJared[i].exists() || tobeJared[i].isDirectory() )
          continue;
       
        // Zielpfad der Datei auf die package-Struktur reduzieren
        path = tobeJared[i].getPath().substring(this.source.length());
        path = path.replaceAll("\\\\", "/");
       
        this.log("\n adding " + path);
       
        // Add archive entry
        jarAdd = new JarEntry(path);
        jarAdd.setTime(tobeJared[i].lastModified());
        out.putNextEntry(jarAdd);
       
        // Klasse ins Archiv schreiben
        FileInputStream in = new FileInputStream(tobeJared[i]);
       
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.