public abstract class StringUtil

  1. Object
  2. StringUtil
Various utility methods for manipulating strings

Constructors

public StringUtil()

Methods

public static void setImplementation(CodenameOneImplementation i)Deprecated
public static String replaceAll(String source, String pattern, String replace)This method replaces all occurrences of the pattern with the replacement String
public static String replaceFirst(String source, String pattern, String replace)This method replaces the first occurrence of the pattern with the replacement String
public static Vector tokenizeString(String source, char separator)Deprecated Breaks a String to multiple strings.
public static Vector tokenizeString(String source, String separator)Deprecated Breaks a String to multiple strings (similar to string tokenizer)
public static List<String> tokenize(String source, char separator)Breaks a String to multiple strings.
public static List<String> tokenize(String source, String separator)Breaks a String to multiple strings (similar to string tokenizer)
public static String join(Iterable strings, String delimiter)Joins a list or array of objects together using the specified delimiter.
public static String join(Object[] strings, String delimiter)Joins a list or array of objects together using the specified delimiter.
public static byte[] getBytes(String s)Helper to get bytes from string with UTF-8 encoding
public static String newString(byte[] b)Helper to get string from bytes with UTF-8 encoding
public static String newString(byte[] b, int offset, int length)Helper to get string from bytes with UTF-8 encoding

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

source String
the String source
pattern String
String to replace in the source
replace String
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

source String
the String source
pattern String
String to replace in the source
replace String
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

source String
the String to break
separator char
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 instead
Breaks a String to multiple strings (similar to string tokenizer)

Parameters

source String
the String to break
separator String
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

source String
the String to break
separator char
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

source String
the String to break
separator String
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

strings Iterable
Objects to be converted to strings.
delimiter String
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

strings Object[]
Objects to be converted to strings.
delimiter String
The delimiter.

Returns

The joined string.

getBytes

public static byte[] getBytes(String s)
Helper to get bytes from string with UTF-8 encoding

Parameters

s String
the string

Returns

the bytes

newString

public static String newString(byte[] b)
Helper to get string from bytes with UTF-8 encoding

Parameters

b byte[]
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

b byte[]
the bytes
offset int
the offset
length int
the length

Returns

the string