Class HttpBaseUtils

java.lang.Object
com.luna.common.net.base.HttpBaseUtils

public class HttpBaseUtils extends Object
Author:
luna@mac 2021年05月12日 09:42
  • Constructor Details

    • HttpBaseUtils

      public HttpBaseUtils()
  • Method Details

    • getConn

      public static HttpURLConnection getConn(String url)
    • doURL

      public static InputStream doURL(String host, String path, String method, Map<String,String> headers, Map<String,String> queries, String body)
      doURL
      Parameters:
      host - 主机地址
      path - 路径
      headers - 请求头
      queries - 请求参数
      body - 请求体
      Returns:
      输入流
    • doURL

      public static InputStream doURL(String host, String path, String method, Map<String,String> headers, Map<String,String> queries, byte[] file)
      doURL
      Parameters:
      host - 主机地址
      path - 路径
      headers - 请求头
      queries - 请求参数
      file - 请求体
      Returns:
      InputStream
    • doURLWithByte

      public static byte[] doURLWithByte(String host, String path, String method, Map<String,String> headers, Map<String,String> queries, File file)
    • doURLWithString

      public static String doURLWithString(String host, String path, String method, Map<String,String> headers, Map<String,String> queries, File file)
    • doURLWithByte

      public static byte[] doURLWithByte(String host, String path, String method, Map<String,String> headers, Map<String,String> queries, String body)
    • doURLWithString

      public static String doURLWithString(String host, String path, String method, Map<String,String> headers, Map<String,String> queries, String body)
    • download

      public static void download(String url, String path)
      流转文件
      Parameters:
      url - 请求地址
      path - 文件路径
    • readWithByte

      public static byte[] readWithByte(InputStream inputStream, int bufferSize)
      流读取字节
      Parameters:
      inputStream - 输入流
      bufferSize - 缓冲区大小
    • readWithString

      public static String readWithString(InputStream inputStream, int bufferSize)
      读取字符
      Parameters:
      inputStream - 输入流
      Returns:
      String
    • readWithReader

      public static String readWithReader(Reader rd)
      读取
      Parameters:
      rd - 输入字符流
      Returns:
      String
    • readWithString

      public static String readWithString(InputStream inputStream, String charsetName)
      字符编码指定格式读取
      Parameters:
      inputStream - 输入流
      charsetName - 编码格式
      Returns:
      String
    • readWithString

      public static String readWithString(InputStream inputStream)
      读取字符
      Parameters:
      inputStream - 输入流
      Returns:
      String
    • readWithByte

      public static byte[] readWithByte(InputStream inputStream)
      读取字节
      Parameters:
      inputStream - 输入流
      Returns:
      String
    • setCookieManager

      public static CookieStore setCookieManager()
    • printCookie

      public static void printCookie(CookieStore cookieStore)