Java 8 ZipInputStream - 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 ZipInputStream class.

This code example shows how to use the following methods:skip, getNextEntry
        zentry = zis.getNextEntry();
        zentry = zis.getNextEntry();
        long s = zis.skip(1025);
        assertTrue("invalid skip: " + s, s == 1025);
 
        ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(
                zipBytes));
        zis.getNextEntry();
        long skipLen = dataBytes.length / 2;
        assertEquals("Assert 0: failed valid skip", skipLen, zis.skip(skipLen));
        zis.skip(dataBytes.length);
        assertEquals("Assert 1: performed invalid skip", 0, zis.skip(1));
        assertEquals("Assert 2: failed zero len skip", 0, zis.skip(0));
        try { 
            zis.skip(-1);
            fail("Assert 3: Expected Illegal argument exception");
        } catch (IllegalArgumentException e) {
            // Expected 
        } 
 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getNextEntry
		outs.close();
		zin.close();
	} 
 
	private ZipInputStream getFileFromZip(InputStream zipFileStream) throws FileNotFoundException, IOException {
		ZipInputStream zis = new ZipInputStream(zipFileStream);
		ZipEntry ze = null;
		while ((ze = zis.getNextEntry()) != null) {
			Log.w(TAG, "extracting file: '" + ze.getName() + "'...");
			return zis;
		} 
		return null; 
	} 
	 
	private String convertStreamToString(InputStream is) { 
	    return new Scanner(is).useDelimiter("\\A").next();
	} 
 
} 
7
CodeRank
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:
	} 
 
	private ZipInputStream getZipInputStream(InputStream is)
		throws FileNotFoundException, IOException 
	{ 
		return new ZipInputStream(is);
	} 
 
	private String getRootDir(ZipInputStream zis)
		throws FileNotFoundException, IOException 
	{ 
		String root = "";
 
		ZipEntry ze = null;
		while((ze = zis.getNextEntry()) != null) {
			String name = ze.getName();
			zis.closeEntry();
 
			if (name.startsWith(MACOSX_PREFIX)) {
				continue; 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close
            reader.setFeature(
                    "http://apache.org/xml/features/nonvalidating/load-external-dtd", 
                    false); 
 
            StringBuilder sb = new StringBuilder();
            ZipInputStream zis = new ZipInputStream(
                    blobHolder.getBlob().getStream());
            try { 
                readXmlZipContent(zis, reader, sb);
            } finally { 
                zis.close();
            } 
            return new SimpleCachableBlobHolder(new StringBlob(sb.toString()));
        } catch (Exception e) {
            throw new ConversionException( 
                    "Error during OpenXml2Text conversion", e);
        } 
    } 
 
    public void init(ConverterDescriptor descriptor) {
6
CodeRank
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:closeEntry, getNextEntry
        ze.setTime(System.currentTimeMillis());
        zos.putNextEntry(ze);
        zos.write("Hello World".getBytes());
        zos.closeEntry();
        zos.close();
        zis = new ZipInputStream(new ByteArrayInputStream(bos.toByteArray()));
        ZipEntry ze2 = zis.getNextEntry();
        zis.closeEntry();
        assertTrue("Failed to write correct entry", ze.getName().equals(
                ze2.getName())
                && ze.getCrc() == ze2.getCrc());
        try { 
            zos.putNextEntry(ze);
            fail("Entry with incorrect setting failed to throw exception");
        } catch (IOException e) {
            // expected 
        } 
    } 
 
    /** 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:skip, getNextEntry
        zentry = zis.getNextEntry();
        zentry = zis.getNextEntry();
        long s = zis.skip(1025);
        assertTrue("invalid skip: " + s, s == 1025);
 
        ZipInputStream zis = new ZipInputStream(new ByteArrayInputStream(
                zipBytes));
        zis.getNextEntry();
        long skipLen = dataBytes.length / 2;
        assertEquals("Assert 0: failed valid skip", skipLen, zis.skip(skipLen));
        zis.skip(dataBytes.length);
        assertEquals("Assert 1: performed invalid skip", 0, zis.skip(1));
        assertEquals("Assert 2: failed zero len skip", 0, zis.skip(0));
        try { 
            zis.skip(-1);
            fail("Assert 3: Expected Illegal argument exception");
        } catch (IllegalArgumentException e) {
            // Expected 
        } 
 
6
CodeRank
Experience pair programming with AI  Get Codota for Java
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
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:getNextEntry
    _in = in;
    _position = position;
 
    in.setPosition(_position);
 
    ZipInputStream zipInputStream = new ZipInputStream(in.getInputStream());
 
    ZipEntry curEntry = zipInputStream.getNextEntry();
 
    if (curEntry == null)
      throw new IOException(
          L.l("ZipEntry at position {0} not found", _position));
 
    init(new ReadStream(new VfsStream(zipInputStream, null)));
  } 
 
  /** 
   * Opens a copy. 
   */ 
  public BinaryInput openCopy() 
6
CodeRank
Experience pair programming with AI  Get Codota for Java

Related Java 8 ZipInputStream Questions & Answers:

See Code Examples for Java 8 ZipInputStream Methods: