1. 程式人生 > >多個刪除,String轉 List

多個刪除,String轉 List

POM

    <!-- tools -->
    <dependency>
      <groupId>commons-collections</groupId>
      <artifactId>commons-collections</artifactId>
      <version>3.2.2</version>
    </dependency>
    <dependency>
      <groupId>commons-codec</groupId
>
<artifactId>commons-codec</artifactId> <version>1.10</version> </dependency>

StringUtil

public class StringUtil {

    public static List<Integer> splitToListInt(String str) {
        List<String> strList = Splitter.on(",").trimResults().
omitEmptyStrings().splitToList(str); return strList.stream().map(strItem -> Integer.parseInt(strItem)).collect(Collectors.toList()); } }