I have quite a lot of streaming data (> 100 MB) which I would like to place in a zip file on an http server for compression. So this zipfile contains one file.
Is it possible for a java client to be able to transfer data via http, even if it is packed into a zip file?
According to Wikipedia, ZIP files are not consistent ...
http://en.wikipedia.org/wiki/ZIP_(file_format)#Structure
If this is still possible, 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 gzip GZipInputStream () GZipOutputStream (). zip gzip , : zip , gzip ( gzip ).
gzip
GZipInputStream
GZipOutputStream
zip
gzip, , .
, HTTPConnection Accept-Encoding: gzip, , Content-Encoding: gzip, , , , .gz (.. Content-Encoding: identity).
Accept-Encoding: gzip
Content-Encoding: gzip
.gz
Content-Encoding: identity
(, , , , Java GZipInputStream zlib.)
( ), :
static void processZippedInputStream(InputStream in, String entryNameRegex) throws IOException { ZipInputStream zin = new ZipInputStream(in); ZipEntry ze; while ((ze = zin.getNextEntry()) != null) { if (ze.getName().matches(entryNameRegex)) { // treat zin as a normal input stream - ie read() from it till "empty" etc break; } zin.closeEntry(); } zin.close(); }
InputStream . , , , ..
- zipping? , , , , , , .:
http://tomcat.apache.org/tomcat-5.5-doc/config/http.html
HTTP/1.1 GZIP. .
. http://en.wikipedia.org/wiki/HTTP_compression.
. , , - , .
, , MIME application/zip
, , , .
, mp3 , ogg/vorbis
GZIP, . Gzip zip.