java 寻找变量引用位置_Java怎么获取变量的地址码?

匿名用户

1级

2016-10-19 回答

如下:

public static String do_post(String url, List name_value_pair) throws IOException {

String body = "{}";

DefaultHttpClient httpclient = new DefaultHttpClient();

try {

HttpPost httpost = new HttpPost(url);

httpost.setEntity(new UrlEncodedFormEntity(name_value_pair, StandardCharsets.UTF_8));

HttpResponse response = httpclient.execute(httpost);

HttpEntity entity = response.getEntity();

body = EntityUtils.toString(entity);

} finally {

httpclient.getConnectionManager().shutdown();

}

return body;

}

public static String do_get(String url) throws ClientProtocolException, IOException {

String body = "{}";

DefaultHttpClient httpclient = new DefaultHttpClient();

try {

HttpGet httpget = new HttpGet(url);

HttpResponse response = httpclient.execute(httpget);

HttpEntity entity = response.getEntity();

body = EntityUtils.toString(entity);

} finally {

httpclient.getConnectionManager().shutdown();

}

return body;

}

匿名用户 1级 2016-10-19 回答 如下: public static String do_post(String url, List name_value_pair) throws IOException { String body = "{}"; DefaultHttpClient httpclient = new DefaultHttpClient(); try { HttpPost httpost = new HttpPost(url); httpost.setEntity(new UrlEncodedFormEntity(name_value_pair, StandardCharsets.UTF_8)); HttpResponse response = httpclient.execute(httpost); HttpEntity entity = response.getEntity(); body = EntityUtils.toString(entity); } finally { httpclient.getConnectionManager().shutdown(); } return body; } public static String do_get(String url) throws ClientProtocolException, IOException { String body = "{}"; DefaultHttpClient httpclient = new DefaultHttpClient(); try { HttpGet httpget = new HttpGet(url); HttpResponse response = httpclient.execute(httpget); HttpEntity entity = response.getEntity(); body = EntityUtils.toString(entity); } finally { httpclient.getConnectionManager().shutdown(); } return body; }
经验分享 程序员 微信小程序 职场和发展