public abstract class StringUtil
- Object
- StringUtil
Various utility methods for manipulating strings
Constructors
public StringUtil() |
Methods
Inherited methods
Constructor details
StringUtil
public StringUtil()Method details
setImplementation
public static void setImplementation(CodenameOneImplementation i)Deprecated. exposed as part of an internal optimization, this method isn’t meant for general access
replaceAll
public static String replaceAll(String source, String pattern, String replace)This method replaces all occurrences of the pattern with the
replacement String
Parameters
sourceString- the String source
patternString- String to replace in the source
replaceString- replacement String
Returns
string with replaced elements
replaceFirst
public static String replaceFirst(String source, String pattern, String replace)This method replaces the first occurrence of the pattern with the
replacement String
Parameters
sourceString- the String source
patternString- String to replace in the source
replaceString- replacement String
Returns
string with replaced elements
tokenizeString
public static Vector tokenizeString(String source, char separator)Deprecated. use the tokenize() method instead
Breaks a String to multiple strings.
Parameters
sourceString- the String to break
separatorchar- the pattern to search and break.
Returns
a Vector of Strings
tokenizeString
public static Vector tokenizeString(String source, String separator)Deprecated. use the
java.lang.String) method insteadBreaks a String to multiple strings (similar to string tokenizer)
Parameters
sourceString- the String to break
separatorString- the characters that can be used to search and break.
Returns
a Vector of Strings
tokenize
public static List<String> tokenize(String source, char separator)Breaks a String to multiple strings.
Parameters
sourceString- the String to break
separatorchar- the pattern to search and break.
Returns
a Vector of Strings
tokenize
public static List<String> tokenize(String source, String separator)Breaks a String to multiple strings (similar to string tokenizer)
Parameters
sourceString- the String to break
separatorString- the characters that can be used to search and break.
Returns
a Vector of Strings
join
public static String join(Iterable strings, String delimiter)Joins a list or array of objects together using the specified delimiter.
Parameters
stringsIterable- Objects to be converted to strings.
delimiterString- The delimiter.
Returns
The joined string.
join
public static String join(Object[] strings, String delimiter)Joins a list or array of objects together using the specified delimiter.
Parameters
stringsObject[]- Objects to be converted to strings.
delimiterString- The delimiter.
Returns
The joined string.
getBytes
public static byte[] getBytes(String s)Helper to get bytes from string with UTF-8 encoding
Parameters
sString- the string
Returns
the bytes
newString
public static String newString(byte[] b)Helper to get string from bytes with UTF-8 encoding
Parameters
bbyte[]- the bytes
Returns
the string
newString
public static String newString(byte[] b, int offset, int length)Helper to get string from bytes with UTF-8 encoding
Parameters
bbyte[]- the bytes
offsetint- the offset
lengthint- the length
Returns
the string