Refine search
public InputStream openClassfile(String classname) throws NotFoundException { try { String jarname = classname.replace('.', '/') + ".class"; JarEntry je = jarfile.getJarEntry(jarname); if (je != null) return jarfile.getInputStream(je); else return null; // not found } catch (IOException e) {} throw new NotFoundException("broken jar file?: " + jarfile.getName()); }
/** * Determine the API level for this SDK jar by inspecting its `build.prop` file. * * If the `ro.build.version.codename` value isn't `REL`, this is an unreleased SDK, which * is represented as `10000` (see {@link android.os.Build.VERSION_CODES#CUR_DEVELOPMENT}. * * @return the API level, or `10000` */ private int readSdkInt() { Properties properties = new Properties(); try (InputStream inputStream = jarFile.getInputStream(jarFile.getJarEntry("build.prop"))) { properties.load(inputStream); } catch (IOException e) { throw new RuntimeException("failed to read build.prop from " + path); } int sdkInt = Integer.parseInt(properties.getProperty("ro.build.version.sdk")); String codename = properties.getProperty("ro.build.version.codename"); if (!"REL".equals(codename)) { sdkInt = 10000; } return sdkInt; }
final JarEntry entry = (entryName != null && jarFile != null) ? jarFile.getJarEntry(entryName) : null; if (entry != null && jarFile != null) { try(InputStream i = jarFile.getInputStream(entry)) { byte[] manifestBytes = IOUtils.toByteArray(i); in = new ByteArrayInputStream(manifestBytes);
JarEntry entry = jarFile.getJarEntry(resourceName); if (entry != null) { return jarFile.getInputStream(entry);
public InputStream openClassfile(String classname) throws NotFoundException { try { String jarname = classname.replace('.', '/') + ".class"; JarEntry je = jarfile.getJarEntry(jarname); if (je != null) return jarfile.getInputStream(je); else return null; // not found } catch (IOException e) {} throw new NotFoundException("broken jar file?: " + jarfile.getName()); }
Collections.sort(names); for (String name : names) { JarEntry inEntry = in.getJarEntry(name); JarEntry outEntry = null; if (inEntry.getMethod() == JarEntry.STORED) { out.putNextEntry(outEntry); InputStream data = in.getInputStream(inEntry); while ((num = data.read(buffer)) > 0) { out.write(buffer, 0, num);
final JarEntry entry = jarFile.getJarEntry(resourceName); if (entry != null) { return jarFile.getInputStream(entry);
protected Class<?> findClassInJarFile(String qualifiedClassName) throws ClassNotFoundException { URI classUri = URIUtil.buildUri(StandardLocation.CLASS_OUTPUT, qualifiedClassName); String internalClassName = classUri.getPath().substring(1); JarFile jarFile = null; try { for (int i = 0; i < jarFiles.size(); i++) { jarFile = jarFiles.get(i); JarEntry jarEntry = jarFile.getJarEntry(internalClassName); if (jarEntry != null) { InputStream inputStream = jarFile.getInputStream(jarEntry); try { byte[] byteCode = new byte[(int) jarEntry.getSize()]; ByteStreams.read(inputStream, byteCode, 0, byteCode.length); return defineClass(qualifiedClassName, byteCode, 0, byteCode.length); } finally { Closeables.closeQuietly(inputStream); } } } } catch (IOException e) { throw new IllegalStateException(String.format("Failed to lookup class %s in jar file %s", qualifiedClassName, jarFile), e); } return null; }
JarEntry entry = jar.getJarEntry("plugin.yml"); stream = jar.getInputStream(entry);
JarFile jar = new JarFile(modelJarPath); LOG(DEBUG, "DEBUG", "Found model jar at: " + modelJarPath); JarEntry astubxJE = jar.getJarEntry(DEFAULT_ASTUBX_LOCATION); if (astubxJE == null) { LOG(VERBOSE, "Warn", "Cannot find jarinfer.astubx in jar: " + modelJarPath); return false; InputStream astubxIS = jar.getInputStream(astubxJE); if (astubxIS == null) { LOG(VERBOSE, "Warn", "Cannot load jarinfer.astubx in jar: " + modelJarPath);
JarEntry entry = state.jarFile.getJarEntry(path); if (entry == null) { throw new FileEntryNotFoundException(); } else { getLabel().setText("Opening: " + name); try (InputStream in = state.jarFile.getInputStream(entry);) { extractSimpleFileEntryToTextPane(in, name, path);
@SuppressFBWarnings("REC_CATCH_EXCEPTION") private ModuleVersion getVersion(File file) { try ( JarFile jar = new JarFile( file ) ) { JarEntry pdf = jar.getJarEntry( "plugin.yml" ); Preconditions.checkNotNull( pdf, "Plugin must have a plugin.yml" ); try ( InputStream in = jar.getInputStream( pdf ) ) { PluginDescription desc = new Yaml().loadAs( in, PluginDescription.class ); return ModuleVersion.parse( desc.getVersion() ); } } catch ( Exception ex ) { ProxyServer.getInstance().getLogger().log( Level.WARNING, "Could not check module from file " + file, ex ); } return null; } }
public static void readFileFromJar(String jarFilePath, String metaInfo) { LogUtil.d("readFileFromJar:", jarFilePath, metaInfo); JarFile jarFile = null; try { jarFile = new JarFile(jarFilePath); JarEntry entry = jarFile.getJarEntry(metaInfo); if (entry != null) { InputStream input = jarFile.getInputStream(entry); return; } } catch (IOException e) { LogUtil.printException("FileUtil.readFileFromJar", e); } finally { if (jarFile != null) { try { jarFile.close(); } catch (IOException e) { LogUtil.printException("FileUtil.readFileFromJar", e); } } } return; }
JarEntry pdf = jar.getJarEntry( "bungee.yml" ); if ( pdf == null ) pdf = jar.getJarEntry( "plugin.yml" ); try ( InputStream in = jar.getInputStream( pdf ) )
public InputStream getJOnASDeploymentDescriptor() throws IOException { JarEntry entry = jarFile.getJarEntry(JONAS_EJB_JAR_FILE_NAME); if (entry != null) { return jarFile.getInputStream(entry); } return null; }
public InputStream getStandardDeploymentDescriptor() throws IOException { JarEntry entry = jarFile.getJarEntry(EJB_JAR_FILE_NAME); if (entry != null) { return jarFile.getInputStream(entry); } return null; }
@Override public InputStream getInputStream() throws IOException { @SuppressWarnings("resource") JarFile jarFile = new JarFile(jar); JarEntry jarEntry = jarFile.getJarEntry(entry); if (jarEntry == null) return null; return jarFile.getInputStream(jarEntry); }
@Override public InputStream getInputStream() throws IOException { @SuppressWarnings("resource") JarFile jarFile = new JarFile(jar); JarEntry jarEntry = jarFile.getJarEntry(entry); if (jarEntry == null) return null; return jarFile.getInputStream(jarEntry); }
public void readXmlFile(){ JarFile jarFile = new JarFile(pathToJar2); JarEntry entry = jarFile.getJarEntry("/test.xml"); InputStream inputStream = jarFile.getInputStream(entry);}
private static InputStream getFileFromJar(String jarFilename, String path) throws Exception { // Look in jar file JarFile f = null; try { f = new JarFile(jarFilename); } catch (Exception e) { } JarEntry ent = f.getJarEntry(path); if (ent != null) { return f.getInputStream(ent); } return null; }