集合初始化指定长度

master
星期八 5 years ago
parent f36b0d8816
commit bb54a2b15e
  1. 3
      src/main/java/com/lq/code/util/sql/SqlUtil.java
  2. 2
      src/main/java/com/lq/wechat/util/MessageUtil.java

@ -73,9 +73,10 @@ public class SqlUtil {
* @return
*/
public static Map<String,String> getAttributeAndColumn(Class entityClazz){
Map<String,String> map=new HashMap<>();
List<Field> fieldsList=BeanUtil.getAllField(entityClazz);
Iterator iterator = fieldsList.iterator();
Map<String,String> map=new HashMap<>(fieldsList.size());
while (iterator.hasNext()){
Field field = (Field) iterator.next();
map.put(field.getName(),caseToHump(field.getName()));

@ -30,13 +30,13 @@ public class MessageUtil {
* @throws DocumentException
*/
public static Map<String, String> xmlToMap(HttpServletRequest req) throws IOException, DocumentException{
Map<String, String> map=new HashMap<>();
SAXReader reader=new SAXReader();
InputStream ins=req.getInputStream();
String resultString=IoUtil.convertStreamToString(ins);
Document doc=DocumentHelper.parseText(resultString);
Element root=doc.getRootElement();
List<Element> list=root.elements();
Map<String, String> map=new HashMap<>(list.size());
for(Element e:list){
map.put(e.getName(), e.getText());
}

Loading…
Cancel
Save