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

This code example shows how to use the following methods: getSize
	} 
 
	private void validateEntryNotEmpty(String fileName, ZipFile reportZip, String reportName) {
	    String entryInZip = reportName + "/" + fileName;
	    ZipEntry entry = reportZip.getEntry(entryInZip);
	    Assert.assertNotNull("Report entry " + fileName + " missing from JDR report " + reportZip.getName(), entry);
	    Assert.assertTrue("Report entry " + fileName + " was empty or could not be determined", entry.getSize() > 0);
	} 
} 
Full Snippet Info
8
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setCrc, setMethod, setSize
        conn.setDefaultUseCaches(false);
        File jar = File.createTempFile("B7050028", ".jar");
        jar.deleteOnExit();
        OutputStream os = new FileOutputStream(jar);
        ZipOutputStream zos = new ZipOutputStream(os);
        ZipEntry ze = new ZipEntry("B7050028.class");
        ze.setMethod(ZipEntry.STORED);
        ze.setSize(len);
        CRC32 crc = new CRC32();
        crc.update(data);
        ze.setCrc(crc.getValue());
        zos.putNextEntry(ze);
        zos.write(data, 0, len);
        zos.closeEntry();
        zos.finish();
        zos.close();
        os.close();
        System.out.println(new URLClassLoader(new URL[] {new URL("jar:" + jar.toURI() + "!/")}, ClassLoader.getSystemClassLoader().getParent()).loadClass(B7050028.class.getName()));
    } 
    private B7050028() {} 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods:
    Files.createParentDirs(file);
    CustomZipOutputStream out = ZipOutputStreams.newOutputStream(file);
    // Sun's java 6 runtime doesn't allow us to create a truly empty zip, but this should be enough 
    // to pass through dx/split-zip without any issue. 
    // ...and Sun's java 7 runtime doesn't let us use an empty string for the zip entry name. 
    out.putNextEntry(new ZipEntry("proguard_no_result"));
    out.close();
  } 
 
  @Override 
  public boolean equals(Object obj) {
    if (obj == null || !(obj instanceof ProGuardObfuscateStep)) {
      return false; 
    } 
    ProGuardObfuscateStep that = (ProGuardObfuscateStep) obj;
 
    return 
        Objects.equal(useAndroidProguardConfigWithOptimizations,
            that.useAndroidProguardConfigWithOptimizations) &&
        Objects.equal(additionalLibraryJarsForProguard,
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setCrc, setMethod, setSize
 
@Provider 
@Produces("application/zip") 
public class ZipWriter implements MessageBodyWriter<Map<String, byte[]>> {
  private static void zipStoreBuffer(ZipArchiveOutputStream zip, String name, byte[] dataBuffer) throws IOException {
    ZipEntry zipEntry = new ZipEntry(name!=null?name: UUID.randomUUID().toString());
    zipEntry.setMethod(ZipOutputStream.STORED);
 
    zipEntry.setSize(dataBuffer.length);
    CRC32 crc32 = new CRC32();
    crc32.update(dataBuffer);
    zipEntry.setCrc(crc32.getValue());
 
    try { 
      zip.putArchiveEntry(new ZipArchiveEntry(zipEntry));
    } catch (ZipException ex) {
      if (name!=null) {
        zipStoreBuffer(zip, "x-"+name, dataBuffer);
        return; 
      } 
Full Snippet Info
7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE
This code example shows how to use the following methods: setCrc, setMethod, setSize, setTime
 
	public void addZipEntry(ZipEntry zipEntry, ZipFile zipFile, String path) throws IOException {
		if (fJarPackage.areDirectoryEntriesIncluded())
			addDirectories(path);
 
		JarEntry newEntry= new JarEntry(path.replace(File.separatorChar, '/'));
 
		if (fJarPackage.isCompressed())
			newEntry.setMethod(ZipEntry.DEFLATED);
			// Entry is filled automatically. 
		else { 
			newEntry.setMethod(ZipEntry.STORED);
			newEntry.setSize(zipEntry.getSize());
			newEntry.setCrc(zipEntry.getCrc());
		} 
 
		long lastModified= System.currentTimeMillis();
 
		// Set modification time 
		newEntry.setTime(lastModified);

7
CodeRank
Stop searching for code, let great code find you!  Add Codota to your java IDE

Related Java 8 ZipEntry Questions & Answers:

See Code Examples for Java 8 ZipEntry Methods: