多個刪除,String轉 List
阿新 • • 發佈:2018-12-10
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());
}
}