| ²é¿´: 4232 | »Ø¸´: 0 | ||
suzikidгæ (³õÈëÎÄ̳)
|
[ÇóÖú]
httpgetÉèÖÃÍøÂ糬ʱʱ¼ä
|
|
package com.example.httpgetpost; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.MalformedURLException; import java.net.URL; import org.apache.http.HttpEntity; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; import org.apache.http.client.methods.HttpGet; import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.params.HttpConnectionParams; import org.apache.http.params.HttpParams; import android.os.Bundle; import android.app.Activity; import android.view.View; import android.view.View.OnClickListener; import android.widget.Button; public class HttpGetPost extends Activity { private Button httpGetButton; private URL url=null; public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); try { url = new URL("http://www.baidu.com/" ;} catch (MalformedURLException e1) { // TODO Auto-generated catch block e1.printStackTrace(); } httpGetButton = (Button)findViewById(R.id.httpget); //httpPostButton = (Button)findViewById(R.id.httppost); httpGetButton.setOnClickListener(new OnClickListener(){ public void onClick(View arg0) { HttpGet httpget = new HttpGet( url.toString() ); InputStream in=null; HttpClient client = new DefaultHttpClient(); HttpParams params = client.getParams(); HttpConnectionParams.setConnectionTimeout(params, 30000); try { HttpResponse response = client.execute( httpget ); HttpEntity httpentity = response.getEntity(); in=httpentity.getContent(); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line=""; String result = ""; while((line=reader.readLine())!=null) { result = result+line; } System.out.println("===========" ;System.out.println(result); } catch (ClientProtocolException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally{ if(in!=null) try { in.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } }); } } XMLÓïÑÔ£º android:layout_width="match_parent" android:layout_height="match_parent" android rientation="vertical" >android:layout_height="wrap_content" android:id="@+id/mTextView" android:text="@string/hello_world" /> android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/httpget" android:text="@string/httpget"/> android:layout_width="wrap_content" android:layout_height="wrap_content" android:id="@+id/httppost" android:text="@string/httppost"/> ΪºÎÔÚ2.3.1ÉÏ¿ÉÒÔÔËÐУ¬µ«ÊÇÔÚ4.0.3ÉÏÈ´²»¿ÉÒÔ£¬¶øÇÒhttpget¿ÉÒÔÓÃÍøÂçurlÂð£¿ÎªÊ²Ã´ºÃÏñÖ»¿ÉÒÔÓñ¾µØurl£¬»»³ÉÍøÂçurl¾ÍÁ¬½Ó²»ÉÏ |
» ²ÂÄãϲ»¶
271²ÄÁϹ¤³ÌÇóµ÷¼Á
ÒѾÓÐ5È˻ظ´
281Çóµ÷¼Á£¨0805£©
ÒѾÓÐ16È˻ظ´
304Çóµ÷¼Á
ÒѾÓÐ6È˻ظ´
²ÄÁϹ¤³Ìר˶µ÷¼Á
ÒѾÓÐ6È˻ظ´
Ò»Ö¾Ô¸Ìì´ó²ÄÁÏÓ뻯¹¤£¨085600£©×Ü·Ö338
ÒѾÓÐ4È˻ظ´
085700×ÊÔ´Óë»·¾³308Çóµ÷¼Á
ÒѾÓÐ3È˻ظ´
Çó²ÄÁϵ÷¼Á
ÒѾÓÐ8È˻ظ´
294Çóµ÷¼Á²ÄÁÏÓ뻯¹¤×¨Ë¶
ÒѾÓÐ5È˻ظ´
Ò»Ö¾Ô¸»ªÖпƼ¼´óѧ£¬080502£¬354·ÖÇóµ÷¼Á
ÒѾÓÐ4È˻ظ´
Ò»Ö¾Ô¸¼ªÁÖ´óѧ²ÄÁÏѧ˶321Çóµ÷¼Á
ÒѾÓÐ6È˻ظ´
ÕÒµ½Ò»Ð©Ïà¹ØµÄ¾«»ªÌû×Ó£¬Ï£ÍûÓÐÓÃŶ~
Ó¢ÎİæÔ°æ¾µä½Ì²Ä ÎÞÏßmeshÍøÂç¼Ü¹¹ÓëÐÒé
ÒѾÓÐ43È˻ظ´
ÕÐÆ¸¡°ÐÅÏ¢¼ìË÷¡¢ÓßÇé·ÖÎö¡¢ÍøÂçÊý¾ÝÀí½âÓëÍÚ¾ò¡±¹¤×÷ÈËÔ±£¨ÖпÆÔº×Ô¶¯»¯Ëù£©
ÒѾÓÐ4È˻ظ´
python urllib2 ÇóÖú°¢
ÒѾÓÐ7È˻ظ´
¿ÉÒÔÓÃGA»òÕßPSOÓÅ»¯Ëã·¨°ÑRBFÉñ¾ÍøÂçµÄÖÐÐÄÖµ,¿í¶ÈºÍȨֵһÆðѵÁ·Âð??
ÒѾÓÐ8È˻ظ´
¿ÆÑдÓСľ³æ¿ªÊ¼£¬ÈËÈËΪÎÒ£¬ÎÒΪÈËÈË













;
rientation="vertical" >
»Ø¸´´ËÂ¥
µã»÷ÕâÀïËÑË÷¸ü¶àÏà¹Ø×ÊÔ´
50