Java 8 JarInputStream - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 JarInputStream class.

This code example shows how to use the following methods:getNextJarEntry, available, close
		System.out.println("jar url is " + url);
		URLConnection con = url.openConnection();
		System.out.println(con);
		System.out.println(con.getContentType());
		InputStream stream = con.getInputStream();
		JarInputStream jis = new JarInputStream(stream);
		System.out.println(jis);
		System.out.println(jis.available());
		System.out.println(jis.getNextJarEntry());
		System.out.println(jis.getNextJarEntry());
		System.out.println(jis.getNextJarEntry());
		System.out.println(jis.available());
		System.out.println(jis.getNextJarEntry());
		System.out.println(jis.available());
		jis.close();
	} 
 
	// @Override 
	// protected OsgiPlatform createPlatform() { 
	// OsgiPlatform platform = super.createPlatform(); 
6
CodeRank
This code example shows how to use the following methods:getManifest
        this.file = file;
        FileInputStream fis = null;
        JarInputStream jar = null;
        try { 
            fis = new FileInputStream(file);
            jar = new JarInputStream(fis);
            Manifest manifest = jar.getManifest();
            if (manifest == null)
                throw new PluginException(name, tr("The plugin file ''{0}'' does not include a Manifest.", file.toString()));
            scanManifest(manifest, false);
            libraries.add(0, Utils.fileToURL(file));
        } catch (IOException e) {
            throw new PluginException(name, e);
        } finally { 
            Utils.close(jar);
            Utils.close(fis);
        } 
    } 
 
    /** 
6
CodeRank
This code example shows how to use the following methods:getManifest, close
 
        Manifest manifest = null;
        JarInputStream jin = null;
 
        try { 
            jin = new JarInputStream(inStream);
            manifest = jin.getManifest();
            jin.close();
            jin = null;
        } finally { 
            if (jin != null) {
                try { 
                    jin.close();
                } catch (Throwable t) {
                    // Ignore 
                } 
            } 
        } 
 
        return manifest;
6
CodeRank
This code example shows how to use the following methods:getManifest
    public Manifest getManifest() throws IOException {
        if (jarFile != null) {
            return jarFile.getManifest();
        } else { 
            try { 
                JarInputStream is = new JarInputStream(new ByteArrayInputStream(this.content));
                return is.getManifest();
            } catch (IOException e) {
                e.printStackTrace();
            } 
        } 
        return null; 
    } 
 
    @Override 
    public void close() { 
        if (jarFile != null) {
            try { 
                jarFile.close();
            } catch (Exception ignored) {
6
CodeRank
This code example shows how to use the following methods:getManifest, close
public class JarUtils { 
 
    public static Manifest loadJarManifest(InputStream stream) throws IOException {
        JarInputStream jarInputStream = null;
        try { 
            jarInputStream = new JarInputStream(stream);
            return jarInputStream.getManifest();
        } finally { 
            if (jarInputStream != null) {
                try { 
                    jarInputStream.close();
                } catch (IOException e) {
                    /* swallow */ 
                } 
            } 
        } 
    } 
} 
6
CodeRank
This code example shows how to use the following methods:getManifest, close
 
        Manifest manifest = null;
        JarInputStream jin = null;
 
        try { 
            jin = new JarInputStream(inStream);
            manifest = jin.getManifest();
            jin.close();
            jin = null;
        } finally { 
            if (jin != null) {
                try { 
                    jin.close();
                } catch (Throwable t) {
                    ExceptionUtils.handleThrowable(t);
                } 
            } 
        } 
 
        return manifest;
6
CodeRank
This code example shows how to use the following methods:getNextEntry, read, close
 
    public void test_read$ZII() throws Exception { 
        File resources = Support_Resources.createTempFolder();
        Support_Resources.copyFile(resources, null, "Broken_entry_data.jar");
        InputStream is = Support_Resources.getStream("Broken_entry_data.jar");
        JarInputStream jis = new JarInputStream(is, true);
        byte b[] = new byte[100];
 
        jis.getNextEntry();
        jis.read(b, 0, 100);
        jis.getNextEntry();
        jis.getNextEntry();
        jis.getNextEntry();
 
        try { 
            jis.read(b, 0, 100);
            fail("ZipException expected");
        } catch (ZipException ee) {
            // expected 
        } 

6
CodeRank
This code example shows how to use the following methods:getManifest, close
        Manifest result = null;
 
        if ( ins != null ) {
            JarInputStream jis = null;
            try { 
                jis = new JarInputStream(ins);
                result= jis.getManifest();
 
            } finally { 
 
                // close the jar stream or the inputstream, if the jar 
                // stream is set, we don't need to close the input stream 
                // since closing the jar stream closes the input stream 
                if (jis != null) {
                    try { 
                        jis.close();
                    } catch (final IOException ignore) {
                    } 
                } else { 
                    try { 
                        ins.close();
6
CodeRank
This code example shows how to use the following methods:getManifest, close
        Manifest result = null;
 
        if ( ins != null ) {
            JarInputStream jis = null;
            try { 
                jis = new JarInputStream(ins);
                result= jis.getManifest();
 
                // SLING-2288 : if this is a jar file, but the manifest is not the first entry 
                //              log a warning 
                if ( rsrc.getURL().endsWith(".jar") && result == null ) {
                    logger.warn("Resource {} does not have the manifest as its first entry in the archive. If this is " + 
                                "a bundle, make sure to put the manifest first in the jar file.", rsrc.getURL());
                } 
            } finally { 
 
                // close the jar stream or the inputstream, if the jar 
                // stream is set, we don't need to close the input stream 
                // since closing the jar stream closes the input stream 
                if (jis != null) {

6
CodeRank
This code example shows how to use the following methods:getManifest
 
	public void testEmptyManifest() throws Exception { 
		Manifest mf = new Manifest();
		mf.getMainAttributes().putValue("foo", "bar");
		createJar(mf);
		in = new JarInputStream(storage.getInputStream());
		assertEquals(mf, in.getManifest());
	} 
 
	public void testJarUtilsReadResource() throws Exception { 
		Manifest mf = new Manifest();
		mf.getMainAttributes().putValue("foo", "bar");
		createJar(mf);
		assertEquals(mf, JarUtils.getManifest(storage.getResource()));
	} 
 
	public void testExportEntries() throws Exception { 
		Manifest mf = new Manifest();
		Attributes attrs = mf.getMainAttributes();
		String[] packages = new String[] { "foo.bar; version:=1", "bar.foo", "hop.trop" };
5
CodeRank
See Code Examples for Java 8 JarInputStream Methods: