public String listToString(List list){
if(list.size() == 0)
return "";
StringBuilder stringBuilder = new StringBuilder();
for(int i=0; i<list.size(); i++){
stringBuilder.append(list.get(i)).append(",");
}
return stringBuilder.toString().substring(0,stringBuilder.toString().length()-1);
}
public List<Integer> stringToList(String s){
List<Integer> list = new ArrayList<Integer>();
if(StringUtil.isEmpty(s))
return list;
String [] strings = s.split(",");
for(String et : strings){
list.add(Integer.parseInt(et));
}
return list;
}
将list转化成String,元素中间加“,”。