no message

main
HUOJIN\92525 2025-08-30 17:54:38 +08:00
parent 4aa9bbc534
commit 00afc73b0d
1 changed files with 10 additions and 10 deletions

View File

@ -1,17 +1,18 @@
package com.youchain.utils;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.compress.utils.IOUtils;
import java.io.DataOutputStream;
import java.io.InputStream;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
@Slf4j
public class HttpPostUtil {
public static String sendPostReq(String api_url, String request){
InputStream instr = null;
public static String sendPostReq(String api_url, String request) {
InputStream instr;
String str = "";
try {
URL url = new URL(api_url);
@ -30,14 +31,13 @@ public class HttpPostUtil {
printout.close();
instr = urlCon.getInputStream();
byte[] bis = IOUtils.toByteArray(instr);
String ResponseString = new String(bis, "UTF-8");
if ((ResponseString == null) || ("".equals(ResponseString.trim()))) {
System.out.println("返回空");
String ResponseString = new String(bis, StandardCharsets.UTF_8);
if (ResponseString.trim().isEmpty()) {
log.error("返回空");
}
str = ResponseString;
}catch (Exception e){
System.out.println("接口异常!");
// throw new Error(e.getMessage());
} catch (Exception e) {
log.error("接口异常!");
}
return str;
}