JDK8 String转List<String> 、List<Integer> 及List转String

复制代码
String  auctionBlockIds="45,46,47";

一、String 转List<String>

List<String> auctionBlockId= Arrays.asList(auctionBlockIds.split(",")).stream().map(block -> (block.trim())).collect(Collectors.toList());
或:Arrays.asList(StringUtils.split("1,2,2,3,4,5,6,6", ",")); 二、List
<String> 转 String String auctionBlockIds=String.join(",",auctionBlockId); 三、 String 转List<Integer> List<Integer> auctionBlockId= Arrays.stream(auctionBlockIds.split(",")).map(s -> Integer.valueOf(s.trim())).collect(Collectors.toList()); 四、List<Integer> 转 String String requisitionLineIds=list.stream().map(requisitionLine->String.valueOf(requisitionLine.getRequisitionLineId())).collect(Collectors.joining(","));
复制代码

 

posted @   哎丫丫呀喂  阅读(5774)  评论(2编辑  收藏  举报
点击右上角即可分享
微信分享提示