Package java.util.jar

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


   
    // We must write every entry from the input JAR to the output JAR, so iterate over the entries:
    // Create a read buffer to transfer data from the input
   
    byte[] buffer = new byte[4096];
    JarEntry entry;
    String path;
    Hashtable inventory = new Hashtable();
   
    int nrOfWrittenFiles = 0;
   
    // add the new files
    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("\\\\", "/");
     
      // Datei ist im Original schon enthalten?
      if ( jarContent.get(path)!=null )
        this.log("\n overwriting " + path);
      else
        this.log("\n      adding " + path);
     
      // Add archive entry
      entry = new JarEntry(path);
      entry.setTime(tobeJared[i].lastModified());
      jarOut.putNextEntry(entry);
     
      // Klasse ins Archiv schreiben
      FileInputStream in = new FileInputStream(tobeJared[i]);
     
      while ( true ) {
       
        int nRead = in.read(buffer, 0, buffer.length);
        if ( nRead <= 0 )
          break;
       
        jarOut.write(buffer, 0, nRead);
      }
     
      inventory.put(entry.getName(), "notnull");
     
      in.close();
      nrOfWrittenFiles++;
    }
   
    // Iterate the entries of the original file
    while ((entry = jarIn.getNextJarEntry()) != null) {
     
      // Exclude the manifest file from the old JAR
      if ("META-INF/MANIFEST.MF".equals(entry.getName())) continue;
     
      // Datei befindet sich bereits im jar
      if ( inventory.get(entry.getName())!=null )
        continue;
     
      // Write the entry to the output JAR
      jarOut.putNextEntry(entry);
      int read;
View Full Code Here

                JarFile jar = conn.getJarFile();

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

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

                    String classname = jarEntry.getName();

                    if (classname.endsWith(".class")) {
                        // have a weird case
                        // WEB-INF/classes/org/atmosphere/samples/chat/ChatAtmosphereHandler.class
                        classname = classname.replace("WEB-INF/classes/", "").replace('\\', '/').replace('/', '.').replace('$', '.');
View Full Code Here

        // single URL parameter
        ruleSetLoader.addFromUrl( RuleSetLoaderTest.class.getResource( "simple.java.drl" ) );
        compilers = (RuleSetCompiler[]) ruleSetLoader.getRuleSets().values().toArray( new RuleSetCompiler[]{} );
        JarInputStream jis = new JarInputStream( new ByteArrayInputStream( compilers[0].getSourceDeploymentJar() ) );
        JarEntry entry = null;
        Map entries = new HashMap();
        Map classNames = new HashMap();

        ByteArrayOutputStream bos = null;

        // get all the entries from the jar
        while ( (entry = jis.getNextJarEntry()) != null )
        {
            bos = new ByteArrayOutputStream();
            copy( jis,
                  bos );
            //we have to remove the namespace datestamp, as its random
            String name = entry.getName();
            classNames.put( name.replaceAll( "_[\\d]+/",
                                             "_/" ),
                            name.replace( '/',
                                          '.' ).substring( 0,
                                                           name.length() - 5 ) );
View Full Code Here

        // single URL parameter
        ruleSetLoader.addFromUrl( RuleSetLoaderTest.class.getResource( "simple.java.drl" ) );
        compilers = (RuleSetCompiler[]) ruleSetLoader.getRuleSets().values().toArray( new RuleSetCompiler[]{} );
        byte[] jarBytes = compilers[0].getBinaryDeploymentJar();
        JarInputStream jis = new JarInputStream( new ByteArrayInputStream( jarBytes ) );
        JarEntry entry = null;
        Map entries = new HashMap();
        Map classNames = new HashMap();

        ByteArrayOutputStream bos = null;

        //get all the entries from the jar
        while ( (entry = jis.getNextJarEntry()) != null )
        {
            bos = new ByteArrayOutputStream();
            copy( jis,
                  bos );
            //we have to remove the namespace datestamp, as its random
            String name = entry.getName();
            classNames.put( name.replaceAll( "_[\\d]+/",
                                             "_/" ),
                            name.replace( '/',
                                          '.' ).substring( 0,
                                                           name.length() - 6 ) );
View Full Code Here

    }

    public void addObject(String name,
                          Object object) throws IOException
    {
        jos.putNextEntry( new JarEntry( name ) );
        ObjectOutput out = new ObjectOutputStream( this.jos );
        out.writeObject( object );
    }
View Full Code Here

    }

    public void addFile(File file,
                        String name) throws IOException
    {
        JarEntry entry = new JarEntry( name );
        addFile( file,
                 entry );
    }
View Full Code Here

    }

    public void addByteArray(byte[] bytes,
                             String name) throws IOException
    {
        jos.putNextEntry( new JarEntry( name ) );
        jos.write( bytes );
    }
View Full Code Here

    }   

    private void addFile(File file,
                         int baseFolderPos) throws IOException
    {
        JarEntry entry = new JarEntry( file.toURL().toExternalForm().substring( baseFolderPos ) );
        addFile( file,
                 entry );
    }
View Full Code Here

      File jarPathFile = new File(jarPath);
      JarFile jarFile;
      try {
        jarFile = new JarFile(jarPathFile);
        String entryPath = path.substring(jarIndex + ".jar!/".length());
        JarEntry entry = jarFile.getJarEntry(entryPath);
        return entry.getTime();
      } catch (IOException e) {
        System.err.println("error in handler path=" + path);
        System.err.println("error in handler jarPath=" + jarPath);
        throw 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.