List of usage examples for java.util.jar JarEntry getName
public String getName()
From source file:com.topclouders.releaseplugin.helper.FileHelper.java
private String getFileName(final JarEntry jarEntry) { final String jarEntryName = jarEntry.getName(); final String connectionEntryName = this.jarURLConnection.getEntryName(); return jarEntryName.startsWith(connectionEntryName) ? jarEntryName.substring(connectionEntryName.length()) : jarEntryName;/*from ww w . j a va2s. c o m*/ }
From source file:de.uni.bremen.monty.moco.util.MontyJar.java
private MontyResource[] getSubResources(boolean showFiles) { ArrayList<MontyResource> list = new ArrayList<>(); Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry x = entries.nextElement(); if (x.getName().startsWith(jarEntry.getName())) { String substring = x.getName().substring(jarEntry.getName().length()); if (!substring.equals("")) { if (showFiles == substring.contains("/")) { if (!showFiles || StringUtils.countMatches(substring, "/") == 1 && substring.indexOf("/") == substring.length() - 1) { list.add(new MontyJar(jarFile, x)); }/*from w ww . j av a2 s . c om*/ } } } } MontyResource[] montyResources = list.toArray(new MontyResource[list.size()]); Arrays.sort(montyResources, comparator); return montyResources; }
From source file:dk.netarkivet.common.utils.batch.ByteJarLoader.java
/** * Constructor for the ByteLoader.// w w w. j ava2 s . com * * @param files * An array of files, which are assumed to be jar-files, but * they need not have the extension .jar */ public ByteJarLoader(File... files) { ArgumentNotValid.checkNotNull(files, "File ... files"); ArgumentNotValid.checkTrue(files.length != 0, "Should not be empty array"); for (File file : files) { try { JarFile jarFile = new JarFile(file); for (Enumeration<JarEntry> e = jarFile.entries(); e.hasMoreElements();) { JarEntry entry = e.nextElement(); String name = entry.getName(); InputStream in = jarFile.getInputStream(entry); ByteArrayOutputStream out = new ByteArrayOutputStream((int) entry.getSize()); StreamUtils.copyInputStreamToOutputStream(in, out); log.trace("Entering data for class '" + name + "'"); binaryData.put(name, out.toByteArray()); } } catch (IOException e) { throw new IOFailure("Failed to load jar file '" + file.getAbsolutePath() + "': " + e); } } }
From source file:org.adscale.testtodoc.TestToDoc.java
private void handleEntry(List<String> res, URLClassLoader loader, JarEntry possibleClass) { String clazzPath = possibleClass.getName(); boolean isClass = clazzPath.endsWith(".class"); if (isClass) { String clazzName = massageToClassPath(clazzPath); Class<?> clazz = loadClass(loader, clazzName); handleClass(res, clazz);/*from ww w . j a v a 2s . co m*/ } }
From source file:net.erdfelt.android.sdkfido.local.JarListing.java
private final void loadJar(File jarfile) throws IOException { JarFile jar = null;/*from w w w . jav a2s.co m*/ try { String name; jar = new JarFile(jarfile); Enumeration<JarEntry> entries = jar.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); name = entry.getName(); add(name); if (!entry.isDirectory() && name.endsWith(".class")) { classlist.add(name); } } } finally { if (jar != null) { jar.close(); } } }
From source file:org.apache.hadoop.hive.ql.exec.tez.HivePreWarmProcessor.java
@Override public void run(Map<String, LogicalInput> inputs, Map<String, LogicalOutput> outputs) throws Exception { if (prewarmed) { /* container reuse */ return;//from w w w . j a v a2s .c o m } for (LogicalInput input : inputs.values()) { input.start(); } for (LogicalOutput output : outputs.values()) { output.start(); } /* these are things that goes through singleton initialization on most queries */ FileSystem fs = FileSystem.get(conf); Mac mac = Mac.getInstance("HmacSHA1"); ReadaheadPool rpool = ReadaheadPool.getInstance(); ShimLoader.getHadoopShims(); URL hiveurl = new URL("jar:" + DagUtils.getInstance().getExecJarPathLocal() + "!/"); JarURLConnection hiveconn = (JarURLConnection) hiveurl.openConnection(); JarFile hivejar = hiveconn.getJarFile(); try { Enumeration<JarEntry> classes = hivejar.entries(); while (classes.hasMoreElements()) { JarEntry je = classes.nextElement(); if (je.getName().endsWith(".class")) { String klass = je.getName().replace(".class", "").replaceAll("/", "\\."); if (klass.indexOf("ql.exec") != -1 || klass.indexOf("ql.io") != -1) { /* several hive classes depend on the metastore APIs, which is not included * in hive-exec.jar. These are the relatively safe ones - operators & io classes. */ if (klass.indexOf("vector") != -1 || klass.indexOf("Operator") != -1) { JavaUtils.loadClass(klass); } } } } } finally { hivejar.close(); } prewarmed = true; }
From source file:com.eviware.soapui.plugins.JarClassLoader.java
private boolean isLibrary(JarEntry jarEntry) { return jarEntry.getName().startsWith(LIB_PREFIX) && jarEntry.getName().endsWith(".jar"); }
From source file:com.eviware.soapui.plugins.JarClassLoader.java
private boolean isScript(JarEntry jarEntry) { return jarEntry.getName().endsWith(".groovy"); }
From source file:com.github.nullstress.asm.SourceSetScanner.java
public Set<String> analyzeJar(URL url) { Set<String> dependencies = new HashSet<String>(); try {//from w w w.ja v a 2s . c o m JarInputStream in = new JarInputStream(url.openStream()); JarEntry entry; while ((entry = in.getNextJarEntry()) != null) { String name = entry.getName(); if (name.endsWith(".class")) { dependencies.add(name.replaceAll("/", ".")); } } in.close(); } catch (IOException e) { e.printStackTrace(); } return dependencies; }
From source file:com.topclouders.releaseplugin.helper.FileHelper.java
private void copyResource(String resourcePath, File destination) { FileHelper.validateArguments(resourcePath, destination); // Iterate on jar entries for (Enumeration<JarEntry> e = jarFile.entries(); e.hasMoreElements();) { JarEntry jarEntry = e.nextElement(); final String jarEntryName = jarEntry.getName(); final String jarConnectionEntryName = this.jarURLConnection.getEntryName(); if (jarEntryName.startsWith(jarConnectionEntryName)) { this.copyJarEntry(jarEntry, destination); }/*from ww w . ja v a 2 s . com*/ } }