[java]
/**
* 下載文件
* @param url
*/
private void downFile(final String url) {
mProgressDialog = new ProgressDialog(activity)
mProgressDialog
mProgressDialog
mProgressDialog
new Thread() {
@Override
public void run() {
DefaultHttpClient client = new DefaultHttpClient()
HttpGet get = new HttpGet(url)
HttpResponse response;
try {
response = client
HttpEntity entity = response
long length = entity
InputStream is = entity
FileOutputStream fileOutputStream = null;
if (is != null) {
File file = new File(PATH + software +
fileOutputStream = new FileOutputStream(file)
byte[] buf = new byte[
int ch =
int count =
while ((ch = is
// baos
fileOutputStream
count += ch;
if (length >
}
}
}
fileOutputStream
if (fileOutputStream != null) {
fileOutputStream
}
update()
} catch (ClientProtocolException e) {
e
} catch (IOException e) {
e
}
}
}
}
private void update() {
//Log
Intent intent = new Intent(Intent
intent
Uri
activity
}
From:http://tw.wingwit.com/Article/program/Java/hx/201311/27089.html