public class StringUtil extends Object
| Constructor and Description |
|---|
StringUtil() |
| Modifier and Type | Method and Description |
|---|---|
static int |
getConsecutiveCharCount(String message,
char ch,
int index)
Get the number of consecutive occurrence of the given char in the given message.
|
static String |
getRepeatedString(String repeat,
int count)
Generate a new string by repeating the given string to given count.
|
static boolean |
isEqual(String a,
String b)
Check the equality of the given two Strings.
|
static int |
parseInteger(String message,
int index)
Parse the integer value from given message that starts after the given index.
|
static int |
parseInteger(String message,
int index,
int digitCount)
Parse the integer value from given message that starts after the given index.
|
static int |
parseInteger(String message,
String key)
Parse the integer value from given message that starts after the given key.
|
static long |
parseLong(String message,
int index)
Parse the integer value from given message that starts after the given index.
|
static long |
parseLong(String message,
int index,
int digitCount)
Parse the integer value from given message that starts after the given index.
|
static long |
parseLong(String message,
String key)
Parse the integer value from given message that starts after the given key.
|
static String |
parseString(String message,
String key,
char... delimiters)
Get the String from the message, that starts after the key and ends before the given delimiter.
|
static String |
parseString(String message,
String key,
String delimiter)
Get the String from the message, that starts after the key and ends before the given delimiter.
|
static void |
parseStringCyclic(String message,
String key,
String delimiter,
List<String> list)
Parse all the strings from given message and keep the key in returning string.
|
static String |
parseStringWithKey(String message,
String key,
String delimiter)
Parse the string from given message and keep the key in returning string.
|
static String |
parseStringWithoutTrim(String message,
String key,
String delimiter)
Get the String from the message, that starts after the key and ends before the given delimiter.
|
static String |
removeLeadingChars(String s,
char ch)
Remove all leading given char from given string.
|
static String |
removeTrailingChars(String s,
char ch)
Remove all trailing given char from given string.
|
static String |
replaceString(String message,
String startingString,
String endString,
String replacement)
Replace a part of string with new string, This method will search for replacing String.
|
static String |
trim(String s,
char ch)
Remove all leading and trailing given char from given string.
|
public static boolean isEqual(String a, String b)
a - First Stringb - Second Stringpublic static String parseString(String message, String key, String delimiter)
message - The message from where expected part will be taken.key - After this string result string will start.delimiter - result string will continue until this value is found.public static String parseStringWithoutTrim(String message, String key, String delimiter)
message - The message from where expected part will be taken.key - After this string result string will start.delimiter - result string will continue until this value is found. If this value is null, then method
will return the substring starting after key and end of the message.public static String parseString(String message, String key, char... delimiters)
message - The message from where expected part will be taken.key - After this string result string will start.delimiters - result string will continue until any char from this value is found.public static String parseStringWithKey(String message, String key, String delimiter)
message - message from where a string will be parsed.key - prefix of searched string.delimiter - ending string of searched string.public static void parseStringCyclic(String message, String key, String delimiter, List<String> list)
message - message from where a string will be parsed.key - prefix of searched string.delimiter - ending string of searched string.list - parsed lines will be appended into this instance sequentially.public static int parseInteger(String message, String key)
message - The message from which integer value should be parsed.key - parsing index will start after first occurrence of this sub-string.public static int parseInteger(String message, int index)
message - The message from which integer value should be parsed.index - parsing index will start from this given index.public static int parseInteger(String message, int index, int digitCount)
message - The message from which integer value should be parsed.index - parsing index will start from this given index.digitCount - number of digit to be parsed as integer.public static long parseLong(String message, String key)
message - The message from which integer value should be parsed.key - parsing index will start after first occurrence of this sub-string.public static long parseLong(String message, int index)
message - The message from which integer value should be parsed.index - parsing index will start from this given index.public static long parseLong(String message, int index, int digitCount)
message - The message from which integer value should be parsed.index - parsing index will start from this given index.digitCount - number of digit to be parsed as integer.public static String removeLeadingChars(String s, char ch)
s - this value will be modified.ch - this char will be ignored from leading positionspublic static String removeTrailingChars(String s, char ch)
s - this value will be modified.ch - this char will be ignored from trailing positionspublic static String trim(String s, char ch)
s - this value will be modified.ch - this char will be ignored from leading and trailing positionspublic static String replaceString(String message, String startingString, String endString, String replacement)
message - This message's part of string will be replaced and returned.startingString - Start index of replacing string will start at the index of this string.endString - End index of the replacing string will be at the index of this string.replacement - Replacing string will be replaced by this Stringpublic static int getConsecutiveCharCount(String message, char ch, int index)
message - String message, where the char will be searched.ch - Consecutive occurrence of this char will be counted into the message. If the first char of the given
index doesn't match with this char, method will immediately return 0 value.index - starting index of the given message, where the given char will be looked for.public static String getRepeatedString(String repeat, int count)
repeat - This string will be repeatedcount - Defines how many times the given repeat string should be repeated.Copyright © 2024. All rights reserved.