xxw1754352621 / java-dev

愿景:提升自我知识容量,扩展自我知识边界
Apache License 2.0
6 stars 2 forks source link

分隔StringTokenizer,拼接StringJoiner,缓冲StringBuilder #39

Open xxw1754352621 opened 4 years ago

xxw1754352621 commented 4 years ago

mybatis的一段源码使用

org.apache.ibatis.logging.jdbc.BaseJdbcLogger#removeBreakingWhitespace

protected String removeBreakingWhitespace(String original) {
    StringTokenizer whitespaceStripper = new StringTokenizer(original);
    StringBuilder builder = new StringBuilder();
    while (whitespaceStripper.hasMoreTokens()) {
        builder.append(whitespaceStripper.nextToken());
        builder.append(" ");
    }
    return builder.toString();
}