StringUtils.join () and String.Join () Purpose: The array or a mosaic character set to splice together to form a new string .
StringUtils.join () method:
Before (1) the need to use the introduction of common-lang3 jar package can be downloaded Quguan network: the Apache official download web page
(2) a method as shown below:
(3) passing substantially This method requires two parameters, the first parameter is passed an arbitrary set or array type, the second parameter is a mosaic character.
List<String> list = new ArrayList<>(); list.add("Mxy"); list.add("StringUtils"); list.add("join"); The Join String = StringUtils.join (List, "-"); // passed in a String List collection, use the "-" sign splicing System.out.println (join); String [] S = new new String [] { "Yuan", "Mxy"}; // passed an array of type String, a "-" sign splicing String join2 StringUtils.join = (S, "-" ); System.out.println(join2);
The results are as follows:
Mxy-StringUtils-join Yuan -Mxy
Or so
List<String> subnetIpList = new ArrayList<>(); for (String item : subnetIpArray) { StringBuffer stringBuffer = new StringBuffer(); stringBuffer.append("'"); stringBuffer.append(item); stringBuffer.append("'"); subnetIpList.add(stringBuffer.toString()); } paramMap.put("subnetIpList", StringUtils.join(subnetIpList, ","));