三种网络接口: Http接口,Apache接口,Android接口 1. Http接口 try { URL url = new URL("http://www.google.com"); HttpURLConnection http = (HttpURLConnection) url.openConnection(); int nRC = http.getResponseCode(); if(nRC == HttpURLConnection.HTTP_OK){ /**获取了数据*/ InputStream is = http.getInputStream(); /**TODO 处理数据*/ is.close(); http.disconnect(); } } catch (Exception e) { } 2.Apache接口 try{ HttpClient hc = new DefaultHttpClient(); HttpGet get = new HttpGet("http://www.google.com"); HttpResponse rp = hc.execute(get); if(rp.getStatusLine().getStatusCode() == HttpStatus.SC_OK){ /**获取了数据*/ InputStream is = rp.getEntity().getContent(); /**TODO 处理数据*/ } } catch (Exception e) { } 3. Android接口 try { /**IP*/ InetAddress inetAdderess = InetAddress.getByName("192.168.1.110"); /**Port*/ Socket client = new Socket(inetAdderess,61203,true); /**取得数据*/ InputStream in = client.getInputStream(); OutputStream out = client.getOutputStream(); /**处理数据*/ out.close(); in.close(); } catch (Exception e) { }