1
我創建了3個xml文件並壓縮到一個zip文件夾中。該文件夾是從服務器發送的。當我通過瀏覽器下載zip文件夾時,其工作正常並可以提取文件。但是,當我從android應用程序下載它並存儲在SD卡中時,它已損壞。我把文件從SD卡拉到電腦並試圖解壓文件夾,它顯示Zip文件夾無效。我下面的代碼給出:android:Zip文件夾無效
DefaultHttpClient httpclient1 = new DefaultHttpClient();
HttpPost httpPostRequest = new HttpPost(
Configuration.URL_FEED_UPDATE);
byte[] responseByte = httpclient1.execute(httpPostRequest,
new BasicResponseHandler()).getBytes();
InputStream is = new ByteArrayInputStream(responseByte);
// ---------------------------------------------------
File file1 = new File(Environment
.getExternalStorageDirectory() + "/ast");
file1.mkdirs();
//
File outputFile = new File(file1, "ast.zip");
FileOutputStream fos = new FileOutputStream(outputFile);
byte[] buffer = new byte[1024];
int len1 = 0;
while ((len1 = is.read(buffer)) != -1) {
fos.write(buffer, 0, len1);
}
fos.close();
is.close();
當我用
ZipInputStream zin = new ZipInputStream(new BufferedInputStream(is));
的ZipInputStream
不能從流存儲值。