public class HttpUtil extends Object
| 限定符和类型 | 类和说明 |
|---|---|
static class |
HttpUtil.HttpResp |
| 构造器和说明 |
|---|
HttpUtil() |
| 限定符和类型 | 方法和说明 |
|---|---|
static String |
bytesToString(byte[] bytes)
将字节数组转换成字符串
|
static HttpUtil.HttpResp |
doGet(String url)
发送GET请求
|
static HttpUtil.HttpResp |
doGet(String url,
Map<String,String> params)
发起get请求,做了http与https的差异处理
|
static HttpUtil.HttpResp |
doHttpGet(URL url)
发送HTTP GET请求
|
static HttpUtil.HttpResp |
doHttpsGet(URL url)
发送HTTPS GET请求
|
static String |
doPost(String requestUrl,
Map<String,String> paramsMap,
Map<String,InputStream> files) |
static String |
getCharset()
获取编码
|
static int |
getConnTimeout()
连接超时时间
|
static byte[] |
getData(org.apache.http.HttpEntity httpEntity)
获取Entity中数据
|
static int |
getReadTimeout()
读取数据超时时间,单位毫秒
|
static void |
setCharset(String charset)
设置默认编码
|
static void |
setConnTimeout(int connTimeout)
设置连接超时时间,单位毫秒
|
static void |
setReadTimeout(int readTimeout)
设置读取超时时间
|
public static HttpUtil.HttpResp doGet(String url, Map<String,String> params)
url - params - public static HttpUtil.HttpResp doHttpGet(URL url)
url - URLpublic static HttpUtil.HttpResp doHttpsGet(URL url)
url - URLpublic static String doPost(String requestUrl, Map<String,String> paramsMap, Map<String,InputStream> files) throws Exception
Exceptionpublic static byte[] getData(org.apache.http.HttpEntity httpEntity)
throws Exception
httpEntity - Exceptionpublic static String bytesToString(byte[] bytes) throws UnsupportedEncodingException
bytes - UnsupportedEncodingExceptionpublic static int getConnTimeout()
public static void setConnTimeout(int connTimeout)
connTimeout - connTimeoutpublic static int getReadTimeout()
public static void setReadTimeout(int readTimeout)
readTimeout - readTimeoutpublic static HttpUtil.HttpResp doGet(String url)
url - URLpublic static String getCharset()
public static void setCharset(String charset)
charset - charsetCopyright © 2016. All Rights Reserved.