*URL可以随意改*/        String uriAPI = "http://192.168.1.100:8080/test/test.jsp?u=wangyi&p=456";         /*建立HTTP Get对象*/        HttpGet httpRequest = new HttpGet(uriAPI);         try         {           /*发送请求并等待响应*/          HttpResponse httpResponse = new DefaultHttpClient().execute(httpRequest);           /*若状态码为200 ok*/          if(httpResponse.getStatusLine().getStatusCode() == 200)            {             /*读*/            String strResult = EntityUtils.toString(httpResponse.getEntity());            /*去没有用的字符*/            strResult = eregi_replace("(\r\n|\r|\n|\n\r)","",strResult);            mTextView1.setText(strResult);           }           else           {             mTextView1.setText("Error Response: "+httpResponse.getStatusLine().toString());           }         }         catch (ClientProtocolException e)         {            mTextView1.setText(e.getMessage().toString());           e.printStackTrace();         }         catch (IOException e)         {            mTextView1.setText(e.getMessage().toString());           e.printStackTrace();         }         catch (Exception e)         {            mTextView1.setText(e.getMessage().toString());           e.printStackTrace();          }

更多相关文章

  1. adb shell input keyevent值所对应的字符
  2. 用Java 在 KSOAP中序列化复杂对象数组实体
  3. Android对象序列化存储
  4. Android GreenDao 建表及 获取SessionDao对象 单例
  5. Android EditText插入字符串到光标所在位置和删除
  6. android非法字符的判定、表情符号的判定
  7. Android将获取到文件的uri转换为字符串的路径
  8. android XML文件常用字符转义
  9. Android 创建一个包含星期的格式字符串

随机推荐

  1. Android颜色透明度设置
  2. Android 事件捕捉和处理流程分析
  3. 【Android】android中Invalidate和postIn
  4. Android中StateListDrawable的种类(状态的
  5. 【安卓开发】Facebook工程师是如何改进他
  6. Android盈利模式,哪种更靠谱?
  7. 在Android设备上运行纯java代码
  8. Google Android内核编译教程
  9. android 在android中教你一行代码判断是
  10. ANDROID深入研究和学习的课程