后端utils分割字符串

/**
* 分割字符串
*
* @return
*/
public static List<String> getIdList(String ids) {
if (StringUtils.isEmpty(ids)) {
return new ArrayList<>();
}
if (!ids.contains(",")) {
List<String> re = new ArrayList<>();
re.add(ids);
return re;
}
String[] idArr = ids.split(",");
List<String> idList = Arrays.asList(idArr);
idList = idList.stream()
.filter(id -> StringUtils.isNotEmpty(id))
.collect(Collectors.toList());
return idList;
}
posted @ 2021-04-19 15:12  丿狂奔的蜗牛  阅读(120)  评论(0编辑  收藏  举报