All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.thksystems.util.lang.StringUtils Maven / Gradle / Ivy

Go to download

Commons for lang, crypto, xml, dom, text, csv, reflection, annotations, parsing, ...

There is a newer version: 4.4.0
Show newest version
/*
 * tksCommons
 *
 * Author : Thomas Kuhlmann (ThK-Systems, http://www.thk-systems.de) License : LGPL (https://www.gnu.org/licenses/lgpl.html)
 */
package de.thksystems.util.lang;

public final class StringUtils {

    private StringUtils() {
    }

    /**
     * Extract all capitals (uppercase characters) of a string.
     * 
    *
  • "hello" -> ""
  • *
  • "Hello" -> "H"
  • *
  • "HelLo" -> "HL"
  • *
  • "hello World. Here I am." -> "WHI"
  • *
  • null -> null
  • *
*/ public static String getCapitals(String s) { if (s == null) { return null; } return s.chars().filter(Character::isUpperCase) .collect(StringBuilder::new, StringBuilder::appendCodePoint, StringBuilder::append) .toString(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy