MCPcopy Create free account
hub / github.com/LisenCoding/cangku / HttpClientUtils

Class HttpClientUtils

boot/src/main/java/com/utils/HttpClientUtils.java:12–41  ·  view source on GitHub ↗

HttpClient工具类

Source from the content-addressed store, hash-verified

10 * HttpClient工具类
11 */
12public class HttpClientUtils {
13
14 /**
15 * @param uri
16 * @return String
17 * @description get请求方式
18 * @author: long.he01
19 */
20 public static String doGet(String uri) {
21
22 StringBuilder result = new StringBuilder();
23 try {
24 String res = "";
25 URL url = new URL(uri);
26 HttpURLConnection conn = (HttpURLConnection) url.openConnection();
27 BufferedReader in = new BufferedReader(new InputStreamReader(conn.getInputStream(), "UTF-8"));
28 String line;
29 while ((line = in.readLine()) != null) {
30 res += line+"\n";
31 }
32 in.close();
33 return res;
34 }catch (Exception e) {
35 e.printStackTrace();
36 return null;
37 }
38
39 }
40
41}
42

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected