算是工作中比较常用的操作,记录一下
逗号分隔字符串转列表

通过 String 的 split() 将字符串分割成数组,然后通过 Stream.of() 将数组转为 Java8 的 stream 流然后进行正常的流操作再通过 collect(Collectors.toList()) 转为 List
列表转逗号分隔字符串

这个操作只需要在 collect() 方法中使用 Collectors.joining(",") 即可
算是工作中比较常用的操作,记录一下

通过 String 的 split() 将字符串分割成数组,然后通过 Stream.of() 将数组转为 Java8 的 stream 流然后进行正常的流操作再通过 collect(Collectors.toList()) 转为 List

这个操作只需要在 collect() 方法中使用 Collectors.joining(",") 即可