當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。