private void exploreJarFile(File jarFile, List <String> classes) { JarInputStream jarStream = null; try { jarStream = new JarInputStream(new FileInputStream(jarFile)); JarEntry entry; while ((entry = jarStream.getNextJarEntry()) != null) { var name = entry.getName(); if (name.endsWith(".class")) { String className = name.substring(0, name.length() - 6); classes.add(className); } } } finally { try { if (jarStream != null) { jarStream.close(); } } catch (IOException e) { } } }
public static string getInternalParserModelName(URL mcoUrl) { string internalParserModelName = null; try { JarEntry je; JarInputStream jis = new JarInputStream(mcoUrl.openConnection().InputStream); while ((je = jis.NextJarEntry) != null) { string fileName = je.Name; jis.closeEntry(); int index = fileName.IndexOf('/'); if (index == -1) { index = fileName.IndexOf('\\'); } if (ReferenceEquals(internalParserModelName, null)) { internalParserModelName = fileName.Substring(0, index); break; } } jis.close(); } catch (IOException e) { Console.WriteLine(e.ToString()); Console.Write(e.StackTrace); } return(internalParserModelName); }