public final class StringUtils extends Object
| Modifier and Type | Method and Description |
|---|---|
static int |
countMatches(String s,
char matchMe)
Counts matches of given Char "matchMe" in given String s
|
static int |
countMatches(String s,
String matchMe) |
static String |
insertLineBreaks(String s,
int col)
Equal to call
insertRepetitive(String, int, String)
with parameter: (s, col, System.lineSeperator()) Useful to limit column length of a string. |
static String |
insertRepetitive(String s,
int col,
String insertMe)
|
static String |
reverseFragments(String regex,
String data)
Example: (regex = "\n");
Converts:
Hey,
this is a simple test to: simple test this is a Hey, |
static String |
trim(char trimChar,
String data)
Equal to
trim(String, char...) with parameter (data,
trimChar) |
static String |
trim(String data,
char... trimChars)
Trims "data" String like
String.trim(), but uses defined
"trimChars". |
static String |
trimAmount(String data,
int count)
Equal to data.substring(count, data.length()-count)
|
static String |
trimAround(String data,
String targetString,
char... trimChars)
Splits data String and trims every substring like
trim(String, char...) does. |
static String |
trimSpaces(String data)
Equal to
trim(char, String) with ' ' as char parameter |
public static String reverseFragments(String regex, String data)
Converts:
Hey,
this is a
simple test
to:
simple test
this is a
Hey,
regex - split chardata - data stringpublic static String trim(char trimChar, String data)
trim(String, char...) with parameter (data,
trimChar)trimChar - char to trimdata - data stringString#trim()},
StringUtils#trim(String, char...)}public static String trimSpaces(String data)
trim(char, String) with ' ' as char parameterdata - string to trimpublic static String trim(String data, char... trimChars)
String.trim(), but uses defined
"trimChars".
data - data stringtrimChars - chars to trimpublic static String trimAmount(String data, int count)
data - data string to trimcount - char count to trimString#substring(int, int)}public static String trimAround(String data, String targetString, char... trimChars)
trim(String, char...) does.
Mind: data.split(targetString)
data - data string to trimtargetString - string to split datatrimChars - chars to trim like in trim(String, char...)String#split(String)},
#trim(String, char...)}public static String insertRepetitive(String s, int col, String insertMe)
String "insertMe" periodically in String s.
Integer col defines insertion period.
Example:
insertRepetitive("abcdefghij", 2, "!")
Results in:
"ab!cd!ef!gh!ij"
if s.length() % col == 0 no insert string will be added at
the end of the data string.
s - data Stringcol - "column length"insertMe - String to insertpublic static String insertLineBreaks(String s, int col)
insertRepetitive(String, int, String)
with parameter: (s, col, System.lineSeperator()) s - data Stringcol - column lengthStringUtils#insertRepetitive(String, int, String)}public static int countMatches(String s, char matchMe)
s - the string to search for matchesmatchMe - the char to search forCopyright © 2014–2015. All rights reserved.