80,469
社区成员




public String posturl(){
String result = "";
InputStream is = null;
try{
HttpPost httppost = new HttpPost("http://aspspider.info/lanjackg2003/Default.aspx");
if(nameValuePairs.isEmpty() == false)
{
BasicNameValuePair NameValuePair1 = new BasicNameValuePair("name","123");
BasicNameValuePair NameValuePair2 = new BasicNameValuePair("psw","456");
List<BasicNameValuePair> list = new ArrayList<BasicNameValuePair>();
list.add(NameValuePair1);
list.add(NameValuePair2);
UrlEncodedFormEntity httpEntity = new UrlEncodedFormEntity(list);
httppost.setEntity(httpEntity);
}
HttpClient httpclient = new DefaultHttpClient();
HttpResponse response = httpclient.execute(httppost);
HttpEntity entity = response.getEntity();
is = entity.getContent();
}catch(Exception e){
return "Fail to establish http connection!";
}
try{
BufferedReader reader = new BufferedReader(new InputStreamReader(is,"utf-8"));
StringBuilder sb = new StringBuilder();
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line + "\n");
}
is.close();
result=sb.toString();
}catch(Exception e){
return "Fail to convert net stream!";
return result;
}