StringUtil { public static String stripAllWhitespace( final String input ) { return stripAllChars( input, Character::isWhitespace ); }  static String escapeLdapFilter( final String input ); static String escapeLdapDN( final String input ); static Map<String, String> convertStringListToNameValuePair( final Collection<String> input, final String separator ); static String join( final Object[] inputs, final String separator ); static String join( final Collection inputs, final String separator ); static String formatDiskSizeforDebug( final long diskSize ); static String formatDiskSize( final long diskSize ); static boolean nullSafeEqualsIgnoreCase( final String value1, final String value2 ); static boolean nullSafeEquals( final String value1, final String value2 ); static String escapeJS( final String input ); static String escapeHtml( final String input ); static String escapeCsv( final String input ); static String escapeJava( final String input ); static String escapeXml( final String input ); static String urlEncode( final String input ); static String urlDecode( final String input ); static byte[] base64Decode( final String input ); static String base32Encode( final byte[] input ); static byte[] base64Decode( final String input, final StringUtil.Base64Options... options ); static String base64Encode( final byte[] input ); static String base64Encode( final byte[] input, final StringUtil.Base64Options... options ); static String padEndToLength( final String input, final int length, final char appendChar ); static List<String> splitAndTrim( final String input, final String seperator ); static Collection<String> whitespaceSplit( final String input ); static String[] createStringChunks( final String str, final int size ); static String collectionToString( final Collection collection ); static String collectionToString( final Collection collection, final String recordSeparator ); static String mapToString( final Map map ); static String mapToString( final Map map, final String keyValueSeparator, final String recordSeparator ); static int[] toCodePointArray( final String str ); static boolean isEmpty( final CharSequence input ); static String defaultString( final String input, final String defaultStr ); static boolean equals( final String input1, final String input2 ); static String truncate( final String input, final int length ); static String truncate( final String input, final int length, final String appendIfTruncated ); static int convertStrToInt( final String string, final int defaultValue ); static String stripAllWhitespace( final String input ); static String stripAllChars( final String input, final Predicate<Character> stripPredicate ); static String insertRepeatedLineBreaks( final String input, final int periodicity ); static String repeatedInsert( final String input, final int periodicity, final String insertValue ); static boolean caseIgnoreContains( final Collection<String> collection, final String value );  }
@Test public void stripAllWhitespace() { final String input = " this is a \n test \t string\r\nsecond line"; final String expected = "thisisateststringsecondline"; Assert.assertEquals( expected, StringUtil.stripAllWhitespace( input ) ); }