安卓论坛下载zip:Android--下载zip压缩文件并解压 2024-05-04 00:46:27 0 0 网上有很多介绍下载文件或者解压zip文件的文章,但是两者结合的不多,在此记录一下下载zip文件并直接解压的方法,直接上代码。 源码下载:http://download.csdn.net/detail/chaoyu168/9717756 下载: import java.io.BufferedInputStream;import java.io.BufferedOutputStream;import java.io.File;import java.io.FileNotFoundException;import java.io.FileOutputStream;import java.io.IOException;import java.io.InputStream;import java.io.OutputStream;import java.net.MalformedURLException;import java.net.URL;import java.net.URLConnection;import android.app.ProgressDialog;import android.content.Context;import android.content.DialogInterface;import android.content.DialogInterface.OnCancelListener;import android.os.AsyncTask;import android.util.Log;public class DownLoaderTask extends AsyncTask<Void, Integer, Long> {private final String TAG = "DownLoaderTask";private URL mUrl;private File mFile;private ProgressDialog mDialog;private int mProgress = 0;private ProgressReportingOutputStream mOutputStream;private Context mContext;public DownLoaderTask(String url,String out,Context context){super();if(context!=null){mDialog = new ProgressDialog(context);mContext = context;}else{mDialog = null;}try {mUrl = new URL(url);String fileName = new File(mUrl.getFile()).getName();mFile = new File(out, fileName);Log.d(TAG, "out="+out+", name="+fileName+",mUrl.getFile()="+mUrl.getFile());} catch (MalformedURLException e) {// TODO Auto-generated catch blocke.printStackTrace();}}@Overrideprotected void onPreExecute() {// TODO Auto-generated method stub//super.onPreExecute();if(mDialog!=null){mDialog.setTitle("Downloading...");mDialog.setMessage(mFile.getName());mDialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);mDialog.setOnCancelListener(new OnCancelListener() {@Overridepublic void o 收藏(0)