Java 实现发送Http 请求 JDK 中提供了一些对无状态协议请求(HTTP)的支持: 首先让我们先构建一个请求类(HttpRequester)。 该类封装了JAVA 实现简单请求的代码,如下: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.net.HttpURLConnection; import java.net.URL; import java.nio.charset.Charset; import java.util.Map; import java.util.Vector; /** * HTTP 请求对象 * * @author YYmmiinngg */ public class HttpRequester { private String defaultContentEncoding; public HttpRequester() { this.defaultContentEncoding = Charset.defaultCharset().name(); } /** * 发送GET 请求 * * @param urlString * URL 地址 * @return 响应对象 * @throws IOException */ public HttpRespons sendGet(String urlString) throws IOException { return this.send(urlString, "GET", null, null); } /** * 发送GET 请求 * * @param urlString * URL 地址 * @param params * 参数集合 * @return 响应对象 * @throws IOException */ public HttpRespons sendGet(String urlString, Map params) throws IOException { return this.send(urlString, "GET", params, null); } /** * 发送GET 请求 * * @param urlString * URL 地址 * @param params * 参数集合 * @param propertys * 请求属性 * @return 响应对象 * @throws IOException */ public HttpRespons sendGet(String urlString, Map params, Map propertys) throws IOException { return this.send(urlString, "GET", params, propertys); } /** * 发送POST 请求 * * @param urlString * URL 地址 * @return 响应对象 * @throws IOException */ public HttpRespons sendPost(String urlString) throws IOException { return this.send(urlString, "POST", null, null); } /** * 发送POST 请求 * * @param urlString * URL 地址 * @param params * 参数集合 * @return 响应对象 * @throws IOException */ public...