java post raw 的示例

java post raw 的示例


public static void httpTest() throws ClientProtocolException, IOException {  

    String url = "http://这里是 http request url";  
    String str = "aid=1\ngid=10040\ncid=1000217";  //这里把参数按照 key=value回车(aid=1\n)的方式组成一个字符串。
  
    HttpClient httpClient = new DefaultHttpClient();  
    HttpPost post = new HttpPost(url);  
    StringEntity postingString = new StringEntity(str);
    post.setEntity(postingString);
    HttpResponse response = httpClient.execute(post);  
    String content = EntityUtils.toString(response.getEntity());  
    // Log.i("test",content);  
    System.out.println(content);  
    result = content;  
}
展开阅读全文

没有更多推荐了,返回首页