HttpClient
public class HttpClientUtil {
public static String get(String url){
//创建请求方式
HttpGet httpGet=new HttpGet(url);
// HttpPost ;
// HttpPut;
// HttpDelete
//创建客户端对象
HttpClient client= HttpClientBuilder.create().build();
//执行请求 获取响应对象
try {
HttpResponse response=client.execute(httpGet);
if(response.getStatusLine().getStatusCode()==200){
//解析结果
return EntityUtils.toString(response.getEntity());
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}
OKHttpClient
public class OkHttpUtil {
public static String get(String url){
//创建客户端对象
OkHttpClient client=new OkHttpClient();
//创建请求对象
Request request&#