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);
	} 
} 
8
CodeRank
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() {} 
7
CodeRank
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,
7
CodeRank
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; 
      } 
7
CodeRank
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
This code example shows how to use the following methods:getComment, getCrc, getMethod, getSize, getTime
      throw new NullPointerException();
    } 
 
    this.parent = parent;
    this.repository = repository;
    this.comment = zipEntry.getComment();
    this.name = RepositoryUtilities.buildName(this, "/");
    this.entryName = IOUtils.getInstance().getFileName(name);
    this.size = zipEntry.getSize();
    this.crc32 = zipEntry.getCrc();
    this.time = zipEntry.getTime();
    this.rawData = bytes;
    final int method = zipEntry.getMethod();
    if (method == ZipEntry.STORED || method == ZipEntry.DEFLATED)
    { 
      this.method = new Integer(method);
    } 
    else 
    { 
      this.method = new Integer(ZipEntry.DEFLATED);
7
CodeRank
This code example shows how to use the following methods:getComment, getName, getSize, getTime
      throw new NullPointerException();
    } 
 
    this.parent = parent;
    this.repository = repository;
    this.comment = zipEntry.getComment();
    this.name = zipEntry.getName();
    this.entryName = IOUtils.getInstance().getFileName(name);
    this.size = zipEntry.getSize();
    this.time = zipEntry.getTime();
    this.rawData = bytes;
  } 
 
  public String getMimeType() throws ContentIOException
  { 
    return repository.getMimeRegistry().getMimeType(this);
  } 
 
  public OutputStream getOutputStream() throws ContentIOException, IOException
  { 
7
CodeRank
This code example shows how to use the following methods:
 
    private static void addFileToZip(File file, String parent, ZipOutputStream zos) throws IOException {
        final FileInputStream is = new FileInputStream(file);
        try { 
            final String entryName = parent == null ? file.getName() : parent + "/" + file.getName();
            zos.putNextEntry(new ZipEntry(entryName));
 
            final BufferedInputStream bis = new BufferedInputStream(is);
            try { 
                copyStream(bis, zos);
            } finally { 
                safeClose(bis);
            } 
 
            zos.closeEntry();
        } finally { 
            safeClose(is);
        } 
    } 
 
7
CodeRank
This code example shows how to use the following methods:setCompressedSize, setCrc, setMethod, setSize
	        // Add ZIP entry to output stream. 
			if (part instanceof OleObjectBinaryPart) {
				// Workaround: Powerpoint 2010 (32-bit) can't play eg WMV if it is compressed! 
				// (though 64-bit version is fine) 
				 
				ZipEntry ze = new ZipEntry(resolvedPartUri);
				ze.setMethod(ZipOutputStream.STORED);
				 
				// must set size, compressed size, and crc-32 
				ze.setSize(bytes.length);
				ze.setCompressedSize(bytes.length);
				 
			    CRC32 crc = new CRC32();
			    crc.update(bytes);	
			    ze.setCrc(crc.getValue());
				 
				zos.putNextEntry(ze);				
			} else { 
				zos.putNextEntry(new ZipEntry(resolvedPartUri));
			} 
7
CodeRank
This code example shows how to use the following methods:getComment, getName, getSize, getTime
      throw new NullPointerException();
    } 
 
    this.repository = repository;
    this.parent = parent;
    this.entryName = IOUtils.getInstance().getFileName(zipEntry.getName());
    this.comment = zipEntry.getComment();
    this.size = zipEntry.getSize();
    this.time = zipEntry.getTime();
    this.entries = new HashMap();
    this.name = RepositoryUtilities.buildName(this, "/") + '/';
  } 
 
  private void updateMetaData(final ZipEntry zipEntry)
  { 
    this.comment = zipEntry.getComment();
    this.size = zipEntry.getSize();
    this.time = zipEntry.getTime();
  } 
 
7
CodeRank

Related Java 8 ZipEntry Questions & Answers:

See Code Examples for Java 8 ZipEntry Methods: