hhthtt

URL url = new URL("php接口路径");
    HttpURLConnection conn = (HttpURLConnection) url.openConnection();
    conn.setConnectTimeout(10000);
    conn.setRequestMethod("GET");
    conn.setDoInput(true);
    conn.setDoOutput(true);
 
 
    // 输出返回结果
    InputStream input = conn.getInputStream();
    int resLen =0;
    byte[] res = new byte[1024];
    StringBuilder sb=new StringBuilder();
    while((resLen=input.read(res))!=-1){
      sb.append(new String(res, 0, resLen));
    }
     
    String jsonStr=sb.toString();

 System.out.println(jsonStr);

分类:

技术点:

相关文章:

  • 2021-12-24
  • 2021-11-13
  • 2022-12-23
  • 2021-06-11
  • 2021-11-19
  • 2021-12-13
  • 2021-11-20
猜你喜欢
  • 2021-06-12
  • 2021-09-02
  • 2021-12-04
  • 2021-12-01
  • 2022-12-23
  • 2021-09-11
  • 2021-12-20
相关资源
相似解决方案