private void loadJarContent(JarURLConnection url, String packageName, Set<InputStream> streams) throws IOException { // Using a JarURLConnection will load the JAR from the cache when using Webstart 1.6 // In Webstart 1.5, the URL will point to the cached JAR on the local filesystem JarFile jarFile = url.getJarFile(); Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); if (entry.getName().startsWith(packageName)) { streams.add(jarFile.getInputStream(entry)); } } }
public void getIntents(String path) { try { JarFile jf = new JarFile(path); InputStream is = jf.getInputStream(jf.getEntry("AndroidManifest.xml")); byte[] xml = new byte[is.available()]; int br = is.read(xml); //Tree tr = TrunkFactory.newTree(); decompressXML(xml); //prt("XML\n"+tr.list()); } catch (Exception ex) { console.log("getIntents, ex: "+ex); ex.printStackTrace(); } } // end of getIntents
JarFile jarFile = (JarFile) jarFiles.get(file); if (jarFile == null && file.isDirectory()) { File resource = new File(file, resourceName); if (resource.exists()) { return Files.newInputStream(resource.toPath()); if (jarFile == null) { if (file.exists()) { jarFile = new JarFile(file); jarFiles.put(file, jarFile); } else { return jarFile.getInputStream(entry);
&& weblogicJarFile.exists() && weblogicJarFile.isFile()) { genericJar = new JarFile(genericJarFile); wlJar = new JarFile(weblogicJarFile); .collect(Collectors.toMap(je -> je.getName().replace('\\', '/'), je -> je, (a, b) -> b)); || genericEntry.getSize() != wlEntry.getSize()) { if (genericEntry.getName().endsWith(".class")) { String classname = genericEntry.getName() .replace(File.separatorChar, '.') .replace('/', '.'); newWLJarFile = new File(weblogicJarFile.getAbsolutePath() + ".temp"); if (newWLJarFile.exists()) { newWLJarFile.delete(); je = replaceEntries.get(je.getName()); is = genericJar.getInputStream(je); } else { is = wlJar.getInputStream(je); newJarStream.putNextEntry(new JarEntry(je.getName()));
public static void fillMetadataFromJar(final FileObject object, final File file) throws ParserConfigurationException, IOException, SAXException { final JarFile jar = new JarFile(file); for (final JarEntry entry : UpdaterUtil.iterate(jar.entries())) { if (entry.getName().matches("META-INF/maven/.*/pom.xml")) { new POMParser(object).read(jar.getInputStream(entry)); break; } } jar.close(); }
try (JarFile jar = new JarFile(f)) { if (entry != null && entry.getName().endsWith(".class")) { try (InputStream is = jar.getInputStream(entry)) { byte[] bytes = loadBytes(is); Class c = defineClass(classname, bytes, 0, bytes.length);
JarFile jar = new JarFile( "path to jar" ); // Opens the jar Enumerator<JarEntry> es = jar.entries(); //Enumerator to the jar entries while( es.hasMoreElements() ) { //Iterates until all entries have been visited JarEntry entry = es.nextElement(); //Gets the next entry in the jar System.out.println( entry.getName() ); //Prints the entry name InputStream in = jar.getInputStream( entry ); //returns an inputstream from the entry ... }
java.util.jar.JarFile jar = new java.util.jar.JarFile(jarFile); java.util.Enumeration enumEntries = jar.entries(); while (enumEntries.hasMoreElements()) { java.util.jar.JarEntry file = (java.util.jar.JarEntry) enumEntries.nextElement(); java.io.File f = new java.io.File(destDir + java.io.File.separator + file.getName()); if (file.isDirectory()) { // if its a directory, create it f.mkdir(); continue; } java.io.InputStream is = jar.getInputStream(file); // get the input stream java.io.FileOutputStream fos = new java.io.FileOutputStream(f); while (is.available() > 0) { // write contents of 'is' to 'fos' fos.write(is.read()); } fos.close(); is.close(); }
JarFile jarFile = jarFiles.get(file); if (jarFile == null && file.isDirectory()) { final File resource = new File(file, resourceName); if (resource.exists()) { return Files.newInputStream(resource.toPath()); if (jarFile == null) { if (file.exists()) { jarFile = new JarFile(file); jarFiles.put(file, jarFile); } else { return jarFile.getInputStream(entry);
&& websphereJarFile.exists() && websphereJarFile.isFile()) { genericJar = new JarFile(genericJarFile); wasJar = new JarFile(websphereJarFile); .collect(Collectors.toMap(je -> je.getName().replace('\\', '/'), je -> je, (a, b) -> b)); || genericEntry.getSize() != wasEntry.getSize()) { if (genericEntry.getName().endsWith(".class")) { = genericEntry.getName().replace(File.separatorChar, '.'); newwasJarFile = new File(websphereJarFile.getAbsolutePath() + ".temp"); if (newwasJarFile.exists()) { newwasJarFile.delete(); je = replaceEntries.get(je.getName()); is = genericJar.getInputStream(je); } else { is = wasJar.getInputStream(je); newJarStream.putNextEntry(new JarEntry(je.getName()));
private static String getJarFileContent(File dependencyFile, String filePathString) throws IOException { String content; JarFile jarFile = new JarFile(dependencyFile); JarEntry jarEntry = (JarEntry) jarFile.getEntry(filePathString); if (jarEntry != null) { List<String> entries = Arrays.stream( IOUtils.toString(jarFile.getInputStream(jarEntry), "UTF-8").trim().split("\\n")) .filter( entry -> { return !entry.startsWith("#") && !entry.trim().isEmpty(); // filter out comments and empty lines }) .collect(Collectors.toList()); content = String.join(",", entries); } else { content = ""; } return content; }
private void loadFromJar(File jarFile) { try (JarFile jar = new JarFile(jarFile)) { for (JarEntry entry : C.enumerable(jar.entries())) { String name = entry.getName(); if (isScenarioFile(name)) { InputStream is = jar.getInputStream(entry); String content = IO.readContentAsString(is); parseOne(content, null); } } } catch (IOException e) { warn(e, "Error loading scenario from jar file"); } }
JarFile jfile = new JarFile(file); ITypeLoader jarLoader = new JarTypeLoader(jfile); throw new TooLargeFileException(entry.getSize()); String entryName = entry.getName(); if (entryName.endsWith(".class")) { getLabel().setText("Extracting: " + name); } else { getLabel().setText("Opening: " + name); try (InputStream in = state.jarFile.getInputStream(entry);) { extractSimpleFileEntryToTextPane(in, name, path);
protected void extractDirFromJar(String jarpath, String dir, Path dest) throws IOException { LOG.debug("EXTRACTING {} from {} and placing it at {}", dir, jarpath, dest); if (!Files.exists(dest)) { //Create the directory no matter what. This is so we can check if it was downloaded in the future. Files.createDirectories(dest); } try (JarFile jarFile = new JarFile(jarpath)) { String toRemove = dir + '/'; Enumeration<JarEntry> jarEnums = jarFile.entries(); while (jarEnums.hasMoreElements()) { JarEntry entry = jarEnums.nextElement(); String name = entry.getName(); if (!entry.isDirectory() && name.startsWith(toRemove)) { String shortenedName = name.substring(toRemove.length()); Path targetFile = dest.resolve(shortenedName); LOG.debug("EXTRACTING {} SHORTENED to {} into {}", name, shortenedName, targetFile); fsOps.forceMkdir(targetFile.getParent()); try (FileOutputStream out = new FileOutputStream(targetFile.toFile()); InputStream in = jarFile.getInputStream(entry)) { IOUtils.copy(in, out); } } else { LOG.debug("Skipping {}", entry); } } } }
/** * Create a default configuration file from the .jar. * * @param name the filename */ protected void createDefaultConfiguration(String name) { File actual = new File(getDataFolder(), name); if (!actual.exists()) { try (JarFile file = new JarFile(getFile())) { ZipEntry copy = file.getEntry("defaults/" + name); if (copy == null) throw new FileNotFoundException(); copyDefaultConfig(file.getInputStream(copy), actual, name); } catch (IOException e) { getLogger().severe("Unable to read default configuration: " + name); } } }
public GoPluginDescriptor build(File pluginJarFile, boolean isBundledPlugin) { if (!pluginJarFile.exists()) { throw new RuntimeException(String.format("Plugin jar does not exist: %s", pluginJarFile.getAbsoluteFile())); } try (JarFile jarFile = new JarFile(pluginJarFile)) { ZipEntry entry = jarFile.getEntry(PLUGIN_XML); if (entry == null) { return GoPluginDescriptor.usingId(pluginJarFile.getName(), pluginJarFile.getAbsolutePath(), getBundleLocation(bundlePathLocation, pluginJarFile.getName()), isBundledPlugin); } try (InputStream pluginXMLStream = jarFile.getInputStream(entry)) { return GoPluginDescriptorParser.parseXML(pluginXMLStream, pluginJarFile.getAbsolutePath(), getBundleLocation(bundlePathLocation, pluginJarFile.getName()), isBundledPlugin); } } catch (Exception e) { LOGGER.warn("Could not load plugin with jar filename:{}", pluginJarFile.getName(), e); String cause = e.getCause() != null ? String.format("%s. Cause: %s", e.getMessage(), e.getCause().getMessage()) : e.getMessage(); return GoPluginDescriptor.usingId(pluginJarFile.getName(), pluginJarFile.getAbsolutePath(), getBundleLocation(bundlePathLocation, pluginJarFile.getName()), isBundledPlugin) .markAsInvalid(Arrays.asList(String.format("Plugin with ID (%s) is not valid: %s", pluginJarFile.getName(), cause)), e); } }
File dir = new File(outputPath); if (!dir.exists()) { dir.mkdirs(); jf = new JarFile(fileName); for (Enumeration<JarEntry> e = jf.entries(); e.hasMoreElements(); ) { JarEntry je = e.nextElement(); String outFileName = outputPath + je.getName(); File f = new File(outFileName); if (je.isDirectory()) { if (!f.exists()) { pf.mkdirs(); InputStream in = jf.getInputStream(je); OutputStream out = new BufferedOutputStream( new FileOutputStream(f));
try ( JarFile pluginJar = new JarFile( extensionJar, false ) ) try ( InputStream is = pluginJar.getInputStream( pluginDescriptorEntry ) ) File pluginXml = new File( extensionJar, getExtensionDescriptorLocation() );
JarFile dexJar = null; try { dexJar = new JarFile(dexOrJarFile); ZipEntry classesDex = dexJar.getEntry(DexFormat.DEX_IN_JAR_NAME); ); return MD5.getMD5(dexJar.getInputStream(classesDex), 1024 * 100); } catch (IOException e) { throw new TinkerPatchException(
public static String mavenCoordinatesFromJarFile(File file) throws IOException { StringBuilder buffer = new StringBuilder(); JarFile jarFile = new JarFile(file); Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { JarEntry jarEntry = entries.nextElement(); String name = jarEntry.getName(); if (name.endsWith("pom.properties")) { InputStream is = jarFile.getInputStream(jarEntry); if (is != null) { appendMavenCoordinateFromPomProperties(is, buffer); } } } return buffer.toString(); } }