byte - java.util.zip.ZipException when adding a ZipEntry to a ZipOutputStream without a ZipInputStream -


i attempting add zipentry zipoutputstream running problems when trying write bytes.

i got zipentry hashmap maps file names zipentries. chose method because dealing large zipinputstream , want able access contents easier looping through inputstream , looking file , getting zipentry.

this causes problem when try write bytes after added entry. solutions have found far have needed zipinputstream.

here code:

zipentry ze = entryhash.get(pathtostring(path)); zos.putnextentry(ze); zos.write(new byte[(int)ze.getsize()]); // problem here zos.closeentry(); 

the error getting is:

java.util.zip.zipexception: invalid entry compressed size (expected 389 got 12 bytes)     @ java.util.zip.zipoutputstream.closeentry(zipoutputstream.java:248) 

how can fix exception?

you need create new zipentry add zipoutputstream. code doesn't make sense. you're not copying old zipentry output technique, you're writing array of 0 bytes of same size. have read old zipentry , write new output. technique of map of zipentries isn't going work either. zip file must processed sequentially.


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -