public class HttpClientUtils extends Object
| 构造器和说明 |
|---|
HttpClientUtils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
bufferedReader2String(BufferedReader reader)
BufferedReader转换成String
注意:流关闭需要自行处理 |
static void |
doOutput(OutputStream out,
byte[] data,
int len)
处理输出
注意:流关闭需要自行处理 |
static Certificate |
getCertificate(File cafile)
获取CA证书信息
|
static HttpsURLConnection |
getHttpsURLConnection(String strUrl)
get HttpsURLConnection
|
static HttpURLConnection |
getHttpURLConnection(String strUrl)
get HttpURLConnection
|
static String |
getQueryString(String strUrl)
获取查询串
|
static SSLContext |
getSSLContext(FileInputStream trustFileInputStream,
String trustPasswd,
FileInputStream keyFileInputStream,
String keyPasswd)
获取SSLContext
|
static String |
getURL(String strUrl)
获取不带查询串的url
|
static byte[] |
InputStreamTOByte(InputStream in)
InputStream转换成Byte
注意:流关闭需要自行处理
|
static String |
InputStreamTOString(InputStream in,
String encoding)
InputStream转换成String
注意:流关闭需要自行处理
|
static void |
putMapByPair(String pair,
Map m)
把键值添加至Map
pair:name=value |
static Map |
queryString2Map(String queryString)
查询字符串转换成Map
name1=key1&name2=key2&... |
static void |
storeCACert(Certificate cert,
String alias,
String password,
OutputStream out)
存储ca证书成JKS格式
|
static char[] |
str2CharArray(String str)
字符串转换成char数组
|
static InputStream |
String2Inputstream(String str) |
public static HttpURLConnection getHttpURLConnection(String strUrl) throws IOException
strUrl - url地址IOExceptionpublic static HttpsURLConnection getHttpsURLConnection(String strUrl) throws IOException
strUrl - url地址IOExceptionpublic static Map queryString2Map(String queryString)
queryString - public static void putMapByPair(String pair, Map m)
pair - name=valuem - public static String bufferedReader2String(BufferedReader reader) throws IOException
reader - IOExceptionpublic static void doOutput(OutputStream out, byte[] data, int len) throws IOException
out - data - len - IOExceptionpublic static SSLContext getSSLContext(FileInputStream trustFileInputStream, String trustPasswd, FileInputStream keyFileInputStream, String keyPasswd) throws NoSuchAlgorithmException, KeyStoreException, CertificateException, IOException, UnrecoverableKeyException, KeyManagementException
trustPasswd - keyPasswd - NoSuchAlgorithmExceptionKeyStoreExceptionIOExceptionCertificateExceptionUnrecoverableKeyExceptionKeyManagementExceptionpublic static Certificate getCertificate(File cafile) throws CertificateException, IOException
cafile - CA证书文件CertificateExceptionIOExceptionpublic static char[] str2CharArray(String str)
str - public static void storeCACert(Certificate cert, String alias, String password, OutputStream out) throws KeyStoreException, NoSuchAlgorithmException, CertificateException, IOException
cert - alias - password - out - KeyStoreExceptionNoSuchAlgorithmExceptionCertificateExceptionIOExceptionpublic static InputStream String2Inputstream(String str)
public static byte[] InputStreamTOByte(InputStream in) throws IOException
in - ExceptionIOExceptionpublic static String InputStreamTOString(InputStream in, String encoding) throws IOException
in - encoding - 编码ExceptionIOExceptionCopyright © 2021. All rights reserved.