利用stream将字符串 12,45,89 转成List
/**
* 将字符串 12,45,89 转成List<Long>
*/
@Test
public void test2() {
String str = "fghj,48,drftyguhji,,";
List<Long> ids = Stream
.of(str.split(","))
//过滤非数字的字符串
.filter(s -> Pattern.matches("^[1-9]\\d*|0$", s))\
//.filter(NumberUtils::isDigits)//import org.apache.commons.lang3.math.NumberUtils;
.map(Long::valueOf)
.collect(Collectors.toList());
System.out.println(ids);
//[48]
}