private List<String> strToListString(String s){ List<String> list = new ArrayList<>(); String[] split = s.split(","); for(int i=0;i<split.length;i++) { list.add(split[i]); } return list; }
private static String listToString(List<String> list){ StringBuilder sb=new StringBuilder(); for (int i = 0; i < list.size(); i++) { if (i != list.size() - 1) { sb.append(list.get(i) + ","); }else{ sb.append(list.get(i)); } } return sb.toString(); }
spring-beans-xx.xx.jar
package org.springframework.beans;
BeanUtils
public static void copyProperties(Object source, Object target, String... ignoreProperties) throws BeansException { copyProperties(source, target, (Class)null, ignoreProperties); }
commons-collections-xx-xx.jar
package org.apache.commons.collections;
CollectionUtils
public static boolean isEmpty(Collection coll) { return (coll == null || coll.isEmpty()); }
commons-lang-xx-xx.jar
package org.apache.commons.lang;
StringUtils
public static boolean isNotEmpty(String str) { return !StringUtils.isEmpty(str); }
public static boolean isEmpty(String str) { return str == null || str.length() == 0; }
异常堆栈信息转字符窜
public static String getErrorInfoFromException(Exception e) { try { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); return " " + sw.toString() + " "; } catch (Exception e2) { return "bad getErrorInfoFromException"; } }
去空格后是否空字符
private boolean isNotEmptyAfterTrim(String s){ if (StringUtils.isNotEmpty(s)){ if (s.trim().length()!=0){ return true; } } return false; }
字符窜格式化