String concatenation

// Method 1: Apache common long3 String fileName = stringutils. join(new String[]{" Production employee performance ", LocalDateTime.now().format(DateTimeFormatter.ofPattern("YYYYMMddHHmmss")), randomAlphanumeric(4).toLowerCase()}, "_"); // aa,bb,cc String join = StringUtils.join(new String[]{"aa","bb","cc"}, ","); / / way 2: guava Joiner. On (" _ "). The join (new String [] {" aa ", "bb"}); / / aa_bb / / way 1: the JDK, change method is the underlying StringJoiner String. Join (" | ", "aa", "bb"); // aa|bb // aa,bb StringJoiner sj = new StringJoiner(",") .add("aa") .add("bb");Copy the code

Handling of exceptions:

// ,bb,cc String join = StringUtils.join(new String[]{null,"bb","cc"}, ","); // null|bb|cc String join1 = String.join("|", new String[]{null, "bb", "cc"}); / / throw exceptions Java. Lang. NullPointerException String join2 = Joiner. On (" _ "). The join (new String [] {null, "bb", "cc"});Copy the code