Package java.util.jar

Examples of java.util.jar.JarEntry


        try {
          addManifest(inJar.getManifest());
          Enumeration entries = inJar.entries();

          while (entries.hasMoreElements()) {
            JarEntry entry = (JarEntry) entries.nextElement();
            InputStream inStream = inJar.getInputStream(entry);

            byte[] bytes = FileUtil.readAsByteArray(inStream);
            String filename = entry.getName();
            // System.out.println("? addJarFile() filename='" + filename
            // + "'");
            UnwovenClassFile classFile = new UnwovenClassFile(new File(outDir, filename).getAbsolutePath(), bytes);

            if (filename.endsWith(".class")) {
              ReferenceType type = this.addClassFile(classFile, false);
              StringBuffer sb = new StringBuffer();
              sb.append(inFile.getAbsolutePath());
              sb.append("!");
              sb.append(entry.getName());
              type.setBinaryPath(sb.toString());
              addedClassFiles.add(classFile);
            }
            // else if (!entry.isDirectory()) {
            //
View Full Code Here


 
  public static NutResource makeJarNutResource(String filePath) {
    JarEntryInfo jeInfo = new JarEntryInfo(filePath);
    try {
      JarFile jar = new JarFile(jeInfo.getJarPath());
      JarEntry entry = jar.getJarEntry(jeInfo.getEntryName());
      if (entry != null) {
        // JDK里面判断实体是否为文件夹的方法非常不靠谱 by wendal
        if (entry.getName().endsWith("/"))// 明显是文件夹
          return null;
        JarEntry e2 = jar.getJarEntry(jeInfo.getEntryName() + "/");
        if (e2 != null) // 加个/,还是能找到?! 那肯定是文件夹了!
          return null;
        return new JarEntryResource(jeInfo);
      }
    }
View Full Code Here

              regex,
              src);
      JarFile jar = new JarFile(jarPath);
      Enumeration<JarEntry> ens = jar.entries();
      while (ens.hasMoreElements()) {
        JarEntry jen = ens.nextElement();
        if (jen.isDirectory())
          continue;
        String name = jen.getName();
        if (name.startsWith(src) && (null == regex || regex.matcher(name).find())) {
          list.add(new JarEntryResource(jar, jen, jen.getName().substring(src.length())));
        }
      }
      if (log.isDebugEnabled())
        log.debugf"Found %s resources in JarFile( %s ) by regex( %s ) base on src ( %s )",
              list.size(),
View Full Code Here

            Manifest mf = in.getManifest();
            if (mf != null) {
                String rubyInit = mf.getMainAttributes().getValue("Ruby-Init");
                if (rubyInit != null) {
                    JarEntry entry = in.getNextJarEntry();
                    while (entry != null && !entry.getName().equals(rubyInit)) {
                        entry = in.getNextJarEntry();
                    }
                    if (entry != null) {
                        IRubyObject old = runtime.getGlobalVariables().isDefined("$JAR_URL") ? runtime.getGlobalVariables().get("$JAR_URL") : runtime.getNil();
                        try {
View Full Code Here

                        }
                    } else {
                        try {
                            List<JarEntry> dirp = new ArrayList<JarEntry>();
                            for(Enumeration<JarEntry> eje = jf.entries(); eje.hasMoreElements(); ) {
                                JarEntry je = eje.nextElement();
                                String name = je.getName();
                                int ix = name.indexOf('/', jar.length());
                                if((!name.startsWith("META-INF") && (ix == -1 || ix == name.length()-1))) {
                                    if("/".equals(jar) || (name.startsWith(jar) && name.length()>jar.length())) {
                                        dirp.add(je);
                                    }
                                }
                            }
                            for(JarEntry je : dirp) {
                                byte[] bs = getBytesInUTF8(je.getName());
                                int len = bs.length;

                                if(je.isDirectory()) {
                                    len--;
                                }

                                if(recursive) {
                                    if(fnmatch(STAR,0,1,bs,0,len,flags) != 0) {
                                        continue;
                                    }
                                    buf.length(0);
                                    buf.append(base, 0, base.length - jar.length());
                                    buf.append( BASE(base) ? SLASH : EMPTY );
                                    buf.append(bs, 0, len);

                                    if(je.isDirectory()) {
                                        int t = buf.realSize;
                                        buf.append(SLASH);
                                        buf.append(DOUBLE_STAR);
                                        buf.append(bytes, m, end - m);
                                        status = glob_helper(cwd, buf.bytes, buf.begin, buf.realSize, t, flags, func, arg);
View Full Code Here

        throws IOException
    {
        FileInputStream fis = new FileInputStream( source );
        try
        {
            jos.putNextEntry( new JarEntry( name ) );
            int count;
            while ( ( count = fis.read( buffer ) ) > 0 )
            {
                jos.write( buffer, 0, count );
            }
View Full Code Here

        if (deploymentExists(contextPath))
            return;
       
        // Checking for a nested /META-INF/context.xml
        JarFile jar = null;
        JarEntry entry = null;
        InputStream istream = null;
        BufferedOutputStream ostream = null;
        File xml = new File
            (configBase, file.substring(0, file.lastIndexOf(".")) + ".xml");
        if (deployXML && !xml.exists()) {
View Full Code Here

        try {
            String noPrefixLocation = location.toString().substring(location.toString().lastIndexOf(":") + 1);
            Parser parser = new Parser(noPrefixLocation);
            InputStream is = location.toURL().openStream();
            String path = "repository/" + parser.getArtifactPath();
            jos.putNextEntry(new JarEntry(path));
            Kar.copyStream(is, jos);
            is.close();
            locationMap.put(location, 1);
        } catch (Exception e) {
            LOGGER.error("Error adding " + location, e);
View Full Code Here

                        : new JarOutputStream(new BufferedOutputStream(new FileOutputStream(temp)), manifest);
                Enumeration en = input.entries();
                byte[] buf = new byte[4096];
                int count;
                while (en.hasMoreElements()) {
                    JarEntry entry = (JarEntry) en.nextElement();
                    if (entry.getName().equals("META-INF/geronimo-plugin.xml")) {
                        entry = new JarEntry(entry.getName());
                        out.putNextEntry(entry);
                        PluginXmlUtil.writePluginMetadata(metadata, out);
                    } else if (entry.getName().equals("META-INF/MANIFEST.MF")) {
                        // do nothing, already passed in a manifest
                    } else {
                        out.putNextEntry(entry);
                        InputStream in = input.getInputStream(entry);
                        while ((count = in.read(buf)) > -1) {
View Full Code Here

                    if (monitor != null) {
                        monitor.writeComplete(total);
                    }
                }
                jar = new JarFile(download);
                JarEntry entry = jar.getJarEntry(driver.unzipPath);
                if (entry == null) {
                    log.error("Cannot extract driver JAR " + driver.unzipPath + " from download file " + url);
                } else {
                    in = jar.getInputStream(entry);
                    repo.copyToRepository(in, (int)entry.getSize(), Artifact.create(uri), monitor);
                }
            } finally {
                if (jar != null) try {
                    jar.close();
                } 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.