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