从服务器下载文件时我需要显示进度条,但我不知道如何获取文件大小。我使用这样的 POST 方法
HttpPost httppost = new HttpPost(url);
Inputstream toDown = null;
List<NameValuePair> nameValuePairs = new ArrayList<NameValuePair>(2);
nameValuePairs.add(new BasicNameValuePair("p1", p1));
nameValuePairs.add(new BasicNameValuePair("p2", p2));
nameValuePairs.add(new BasicNameValuePair("p3", p3));
httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
//Execute HTTP Post Request
HttpResponse response = httpclient.execute(httppost);
if(response.getStatusLine().getStatusCode()!=200){
toDown = null;
}
else{
toDown = response.getEntity().getContent();
}
但我不知道如何处理这些信息来获取文件大小