高效拼接一个GET请求URL
private String getUrl(HashMap<String, String> params) {
String url = Constants.URL_CS_DATA;
// 添加url参数
if (params != null) {
Iterator<String> it = params.keySet().iterator();
StringBuffer sb = null;
while (it.hasNext()) {
String key = it.next();
String value = params.get(key);
if (sb == null) {
sb = new StringBuffer();
sb.append("?");
} else {
sb.append("&");
}
sb.append(key);
sb.append("=");
sb.append(value);
}
url += sb.toString();
}
return url;
}