<分区>
Possible Duplicate:
Android: HTTP communication should use “Accept-Encoding: gzip”
我的 Android 应用程序下载 temp.bin
文件,但今天它(文件)太大了。我将 Apache 配置为使用 gzip
将其压缩为 temp.bin.gz
。所以我得到了实际尺寸的 10%。
到目前为止一切顺利。现在的问题是如何在Android端下载时解压。
我之前用过这个下载算法 fragment :
URL url = new URL(urlStr);
// set redirect mode ...
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setInstanceFollowRedirects(true);
connection.setConnectTimeout(0);
connection.setReadTimeout(0);
connection.setUseCaches(false);
connection.setAllowUserInteraction(false);
connection.connect();
....
InputStream in = null;
//boolean lengthValid = (contentLength != -1);
byte bytes[] = new byte[256];
int total_count = 0;
int max_count = 0;
try {
in = connection.getInputStream();
int count = 0;
while (count != -1){
count = in.read(bytes);
....
我们将不胜感激任何和所有建议。