当前位置: 首页>>代码示例>>Java>>正文


Java JarInputStream.getNextJarEntry方法代码示例

本文整理汇总了Java中java.util.jar.JarInputStream.getNextJarEntry方法的典型用法代码示例。如果您正苦于以下问题:Java JarInputStream.getNextJarEntry方法的具体用法?Java JarInputStream.getNextJarEntry怎么用?Java JarInputStream.getNextJarEntry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.jar.JarInputStream的用法示例。


在下文中一共展示了JarInputStream.getNextJarEntry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processJar

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
/**
 * Store all class names found in this jar file
 */
private static LinkedList<String> processJar(File jarfile, String basepath) {
	// System.out.println("Processing JAR " + jarfile.getPath());
	LinkedList<String> addlist = new LinkedList<String>();
	try {
		JarInputStream jarIS = new JarInputStream(new FileInputStream(
				jarfile));

		JarEntry entry = null;
		while ((entry = jarIS.getNextJarEntry()) != null) {
			String name = entry.getName();
			if (name.endsWith(".class")) {
				// System.out.println( entry.getAttributes().toString() );
				if (!add(name, jarfile.getPath(), basepath).isEmpty())
					addlist.addAll(add(name, jarfile.getPath(), basepath));
			}
		}
	} catch (Exception e) {
	}
	return addlist;
}
 
开发者ID:etomica,项目名称:etomica,代码行数:24,代码来源:Lister.java

示例2: readFromJarFile

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
@SuppressWarnings("resource")
  private List<String> readFromJarFile(String jarPath, String splashedPackageName) throws IOException {
      if (logger.isDebugEnabled()) {
          logger.debug("从JAR包中读取类: {}", jarPath);
      }
      
JarInputStream jarIn = new JarInputStream(new FileInputStream(jarPath));
      JarEntry entry = jarIn.getNextJarEntry();

      List<String> nameList = new ArrayList<>();
      while (null != entry) {
          String name = entry.getName();
          if (name.startsWith(splashedPackageName) && isClassFile(name)) {
              nameList.add(name);
          }

          entry = jarIn.getNextJarEntry();
      }

      return nameList;
  }
 
开发者ID:toulezu,项目名称:io-command,代码行数:22,代码来源:ClasspathPackageScanner.java

示例3: scanJar

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
protected void scanJar(URL jarUrl, Map<String, ResourceInfo> resInfos) throws IOException {
  JarInputStream jarInput = new JarInputStream(jarUrl.openStream(), false);
  JarEntry entry = null;
  while((entry = jarInput.getNextJarEntry()) != null) {
    String entryName = entry.getName();
    if(entryName != null && entryName.endsWith(".class")) {
      final String className = entryName.substring(0,
               entryName.length() - 6).replace('/', '.');
      if(!resInfos.containsKey(className)) {
        ClassReader classReader = new ClassReader(jarInput);
        ResourceInfo resInfo = new ResourceInfo(null, className, null);
        ResourceInfoVisitor visitor = new ResourceInfoVisitor(resInfo);

        classReader.accept(visitor, ClassReader.SKIP_CODE |
            ClassReader.SKIP_DEBUG | ClassReader.SKIP_FRAMES);
        if(visitor.isCreoleResource()) {
          resInfos.put(className, resInfo);
        }
      }
    }
  }

  jarInput.close();
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:25,代码来源:Plugin.java

示例4: dumpJarContent

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
/**
 * Dumps the entries of a jar and return them as a String. This method can
 * be memory expensive depending on the jar size.
 * 
 * @param jis
 * @return
 * @throws Exception
 */
public static String dumpJarContent(JarInputStream jis) {
	StringBuilder buffer = new StringBuilder();

	try {
		JarEntry entry;
		while ((entry = jis.getNextJarEntry()) != null) {
			buffer.append(entry.getName());
			buffer.append("\n");
		}
	}
	catch (IOException ioException) {
		buffer.append("reading from stream failed");
	}
	finally {
		closeStream(jis);
	}

	return buffer.toString();
}
 
开发者ID:eclipse,项目名称:gemini.blueprint,代码行数:28,代码来源:JarUtils.java

示例5: copyJarFile

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
static void copyJarFile(JarInputStream in, JarOutputStream out) throws IOException {
    if (in.getManifest() != null) {
        ZipEntry me = new ZipEntry(JarFile.MANIFEST_NAME);
        out.putNextEntry(me);
        in.getManifest().write(out);
        out.closeEntry();
    }
    byte[] buffer = new byte[1 << 14];
    for (JarEntry je; (je = in.getNextJarEntry()) != null; ) {
        out.putNextEntry(je);
        for (int nr; 0 < (nr = in.read(buffer)); ) {
            out.write(buffer, 0, nr);
        }
    }
    in.close();
    markJarFile(out);  // add PACK200 comment
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:18,代码来源:Utils.java

示例6: getFromJARFile

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
private static Set<Class<?>> getFromJARFile(final String jar, final String packageName)
        throws ClassNotFoundException, IOException {

    final Set<Class<?>> classes = new HashSet<Class<?>>();
    final JarInputStream jarFile = new JarInputStream(new FileInputStream(jar));
    JarEntry jarEntry;
    do {
        jarEntry = jarFile.getNextJarEntry();
        if (jarEntry != null) {
            String className = jarEntry.getName();
            if (className.endsWith(".class")) {
                className = stripFilenameExtension(className);
                if (className.startsWith(packageName)) {
                    classes.add(Class.forName(className.replace('/', '.')));
                }
            }
        }
    }
    while (jarEntry != null);
    jarFile.close();
    return classes;
}
 
开发者ID:testIT-LivingDoc,项目名称:livingdoc-intellij,代码行数:23,代码来源:ClassUtils.java

示例7: getClasses

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
private ArrayList<String> getClasses(File jar) {
    ArrayList<String> classes = new ArrayList<String>();
    try {
        JarInputStream jarStream = new JarInputStream(new FileInputStream(jar));
        JarEntry jarEntry;
        while (true) {
            jarEntry = jarStream.getNextJarEntry();
            if (jarEntry == null)
                break;
            if (jarEntry.getName().endsWith(".class")) {
                classes.add(jarEntry.getName());
            }
        }
        jarStream.close();
    } catch (Exception e) {
        e.printStackTrace();
    }
    return classes;
}
 
开发者ID:FountainMC,项目名称:FountainVanilla,代码行数:20,代码来源:WetPluginManager.java

示例8: jar

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
private List<String> jar(JarInputStream jarStream) throws IOException {
    List<String> classNames = new ArrayList<>();

    JarEntry entry;
    while ((entry = jarStream.getNextJarEntry()) != null) {
        if (entry.isDirectory() || !entry.getName().endsWith(".class")) {
            continue;
        }
        String className = entry.getName();
        className = className.replaceFirst(".class$", "");

        //war files are treated as .jar files, so takeout WEB-INF/classes
        className = StringUtils.removeStart(className, "WEB-INF/classes/"); 

        className = className.replace('/', '.');
        classNames.add(className);
    }

    return classNames;
}
 
开发者ID:txazo,项目名称:struts2,代码行数:21,代码来源:DefaultClassFinder.java

示例9: getContentsFromJarfile

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
/**
 * @return The list of paths of files stored in this Jar.
 */
public List<String> getContentsFromJarfile() {
    JarInputStream jarIn = JarReader.openJar(m_jarPath);
    List<String> files = new ArrayList<String>();
    try {
        JarEntry catEntry = null;
        while ((catEntry = jarIn.getNextJarEntry()) != null) {
            files.add(catEntry.getName());
        }
    } catch (Exception ex) {
        return null;
    }
    return files;
}
 
开发者ID:s-store,项目名称:sstore-soft,代码行数:17,代码来源:JarReader.java

示例10: listResources

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
/**
 * List the names of the entries in the given {@link JarInputStream} that begin with the
 * specified {@code path}. Entries will match with or without a leading slash.
 *
 * @param jar  The JAR input stream
 * @param path The leading path to match
 * @return The names of all the matching entries
 * @throws IOException If I/O errors occur
 */
protected List<String> listResources(JarInputStream jar, String path) throws IOException {
    // Include the leading and trailing slash when matching names
    if (!path.startsWith("/")) {
        path = "/" + path;
    }
    if (!path.endsWith("/")) {
        path = path + "/";
    }

    // Iterate over the entries and collect those that begin with the requested path
    List<String> resources = new ArrayList<String>();
    for (JarEntry entry; (entry = jar.getNextJarEntry()) != null; ) {
        if (!entry.isDirectory()) {
            // Add leading slash if it's missing
            String name = entry.getName();
            if (!name.startsWith("/")) {
                name = "/" + name;
            }

            // Check file name
            if (name.startsWith(path)) {
                if (log.isDebugEnabled()) {
                    log.debug("Found resource: " + name);
                }
                // Trim leading slash
                resources.add(name.substring(1));
            }
        }
    }
    return resources;
}
 
开发者ID:zouzhirong,项目名称:configx,代码行数:41,代码来源:SpringBootExecutableJarVFS.java

示例11: extractClassesFromJAR

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
private static List<Class<Class>> extractClassesFromJAR(File jar, ClassLoader cl) throws IOException { 
    List<Class<Class>> classes = new ArrayList<Class<Class>>();
    JarInputStream jaris = new JarInputStream(new FileInputStream(jar));
    JarEntry ent = null;
    while ((ent = jaris.getNextJarEntry()) != null) {
        if (ent.getName().toLowerCase().endsWith(".class")) {
            try {
                Class<Class> cls = (Class<Class>) cl.loadClass(ent.getName().substring(0, ent.getName().length() - 6).replace('/', '.'));
                if (JPluginLoader.isPluggableClass(cls)) {
                    classes.add((Class<Class>)cls);
                }
            } catch (ClassNotFoundException e) {
                String msg = "";
                if(lang != null) {
                    msg = String.format(lang.getProperty("cant_load_class", "Could not load Class \"%s\""), ent.getName());
                } else {
                    msg = "Can't load Class " + ent.getName();
                }
                if(logger != null) {
                    logger.logErr(msg, false);
                } else {
                    System.err.println(msg);
                }
                e.printStackTrace();
            }
        }
    }
    jaris.close();
    return classes;
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:32,代码来源:JPluginLoader.java

示例12: findFile

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
public static List<String> findFile(String fileName, URL url) throws Exception {
    JarInputStream jarInputStream = new JarInputStream(url.openStream());
    for (JarEntry e; (e = jarInputStream.getNextJarEntry()) != null;) {
        Path path = Paths.get(e.getName());
        if (path.getFileName().toString().equals(fileName)) {
            List<String> lines = new ArrayList<>();
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader
                    (jarInputStream));
            lines.addAll(bufferedReader.lines().collect(Collectors.toList()));
            return lines;
        }
    }
    return new ArrayList<>();
}
 
开发者ID:PizzaCrust,项目名称:IodineToolkit,代码行数:15,代码来源:CSVReader.java

示例13: jarContains

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
static boolean jarContains(JarInputStream jis, String entryName)
    throws IOException
{
    JarEntry e;
    boolean found = false;
    while((e = jis.getNextJarEntry()) != null) {
        if (e.getName().equals(entryName))
            return true;
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:12,代码来源:CLICompatibility.java

示例14: jarContains

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
static boolean jarContains(JarInputStream jis, String entryName)
    throws IOException
{
    JarEntry e;
    while((e = jis.getNextJarEntry()) != null) {
        if (e.getName().equals(entryName))
            return true;
    }
    return false;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:Basic.java

示例15: writeLoaderClasses

import java.util.jar.JarInputStream; //导入方法依赖的package包/类
/**
 * Write the required spring-boot-loader classes to the JAR.
 * @throws IOException if the classes cannot be written
 */
public void writeLoaderClasses() throws IOException {
	URL loaderJar = getClass().getClassLoader().getResource(NESTED_LOADER_JAR);
	JarInputStream inputStream = new JarInputStream(
			new BufferedInputStream(loaderJar.openStream()));
	JarEntry entry;
	while ((entry = inputStream.getNextJarEntry()) != null) {
		if (entry.getName().endsWith(".class")) {
			writeEntry(entry, new InputStreamEntryWriter(inputStream, false));
		}
	}
	inputStream.close();
}
 
开发者ID:philwebb,项目名称:spring-boot-concourse,代码行数:17,代码来源:JarWriter.java


注:本文中的java.util.jar.JarInputStream.getNextJarEntry方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。