public class Utils extends Object
| 限定符和类型 | 字段和说明 |
|---|---|
private static boolean |
debug
是否开启debug,
|
static String |
ENTITY_BYTES |
static String |
ENTITY_FILE |
static String |
ENTITY_INPUTSTREAM |
static String |
ENTITY_MULTIPART |
static String |
ENTITY_SERIALIZABLE |
static String |
ENTITY_STRING |
private static org.slf4j.Logger |
logger |
private static List<String> |
SPECIAL_ENTITIY |
| 构造器和说明 |
|---|
Utils() |
| 限定符和类型 | 方法和说明 |
|---|---|
static Map<String,Object> |
buildParas(String paras)
生成参数
参数格式:k1=v1&k2=v2
|
static Map<String,Object> |
buildParas(String[][] paras)
生成参数
参数类型:{{"k1","v1"},{"k2","v2"}}
|
static String |
checkHasParas(String url,
List<org.apache.http.NameValuePair> nvps,
String encoding)
检测url是否含有参数,如果有,则把参数加到参数列表中
|
static void |
debug()
开启打印日志
|
static void |
debug(boolean debug)
开启或关闭打印日志
|
static void |
error(String msg)
打印错误消息
|
static void |
errorException(String msg,
Throwable t)
打印错误消息和异常堆栈
|
static void |
exception(Throwable t)
打印异常堆栈
|
static void |
info(String msg)
打印消息
|
static void |
infoException(String msg,
Throwable t)
打印消息和异常堆栈
|
static org.apache.http.HttpEntity |
map2HttpEntity(List<org.apache.http.NameValuePair> nvps,
Map<String,Object> map,
String encoding)
参数转换,将map中的参数,转到参数列表中
|
private static void |
removeContentTypeCharset(String encoding,
org.apache.http.HttpEntity entity)
移除content-type中的charset
|
private static boolean debug
private static final org.slf4j.Logger logger
public static String checkHasParas(String url, List<org.apache.http.NameValuePair> nvps, String encoding) throws UnsupportedEncodingException
url - 资源地址nvps - 参数列表encoding - 编码UnsupportedEncodingException - 不支持的编码异常public static org.apache.http.HttpEntity map2HttpEntity(List<org.apache.http.NameValuePair> nvps, Map<String,Object> map, String encoding) throws UnsupportedEncodingException
nvps - 参数列表map - 参数列表(map)encoding - 编码UnsupportedEncodingException - 不支持的编码异常private static void removeContentTypeCharset(String encoding, org.apache.http.HttpEntity entity)
encoding - 编码entity - 请求参数及数据信息public static Map<String,Object> buildParas(String paras)
paras - 参数列表public static Map<String,Object> buildParas(String[][] paras)
paras - 参数列表public static void info(String msg)
msg - 消息public static void infoException(String msg, Throwable t)
msg - 异常消息t - 异常public static void error(String msg)
msg - 异常消息public static void errorException(String msg, Throwable t)
msg - 异常消息t - 异常public static void exception(Throwable t)
t - 异常public static void debug()
public static void debug(boolean debug)
debug - 是否开启debugCopyright © 2023. All rights reserved.