I have quite some amount of streamable data (>100MB), which, for the sake of compression, i would like to host packed in a zipfile on an http-server. So this zipfile contains a single file.
Now is it possible for a java-client to stream the data via http, even though it is packed in a zipfile?
According to wikipedia, ZIPs are not sequentially…
http://en.wikipedia.org/wiki/ZIP_(file_format)#Structure
If this is still possible somehow, then how?
edit: about gzip: as i said, i use a custom java client (not a webbrowser) is gzip available in the java http implementation?
Java supports the
gzipformat with theGZipInputStream(decompressing) andGZipOutputStream(compressing). Bothzipandgzipuse the same compressing format internally, the main difference is in the metadata:ziphas it at the end of the file,gzipat the beginning (andgziponly supports one enclosed file easily).For your of streaming one big file, using
gzipwill be the better thing to do – even more as you don’t need access to the metadata.I’m not sure if the HTTPConnection sends
Accept-Encoding: gzipand then handles inflating the content automatically if the server delivers it withContent-Encoding: gzip, but you surely can do it manually if the server simply sends a the.gzfile as such (i.e. withContent-Encoding: identity).(By the way, make sure to read from the stream with not too small buffers, as each deflate call will have a native call overhead, since Java’s GZipInputStream uses the native zlib implementation.)