# Class StringUtil

java.lang.Object
com.codename1.util.StringUtil

public abstract class StringUtil extends Object
Various utility methods for manipulating strings

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `StringUtil()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static byte[]`
  `getBytes(String s)`
  Helper to get bytes from string with UTF-8 encoding
  `static String`
  `join(Iterable strings, String delimiter)`
  Joins a list or array of objects together using the specified delimiter.
  `static String`
  `join(Object[] strings, String delimiter)`
  Joins a list or array of objects together using the specified delimiter.
  `static String`
  `newString(byte[] b)`
  Helper to get string from bytes with UTF-8 encoding
  `static String`
  `newString(byte[] b, int offset, int length)`
  Helper to get string from bytes with UTF-8 encoding
  `static String`
  `replaceAll(String source, String pattern, String replace)`
  This method replaces all occurrences of the pattern with the replacement String
  `static String`
  `replaceFirst(String source, String pattern, String replace)`
  This method replaces the first occurrence of the pattern with the replacement String
  `static void`
  `setImplementation(com.codename1.impl.CodenameOneImplementation i)`

  ###### Deprecated

  `static List<String>`
  `tokenize(String source, char separator)`
  Breaks a String to multiple strings.
  `static List<String>`
  `tokenize(String source, String separator)`
  Breaks a String to multiple strings (similar to string tokenizer)
  `static Vector`
  `tokenizeString(String source, char separator)`
  Breaks a String to multiple strings.
  `static Vector`
  `tokenizeString(String source, String separator)`
  Breaks a String to multiple strings (similar to string tokenizer)

  ### Methods inherited from class Object

  `clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### StringUtil

    public StringUtil()

- ## Method Details

  - ### setImplementation

    public static void setImplementation(com.codename1.impl.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`: the String source

    - `pattern`: String to replace in the source

    - `replace`: 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`: the String source

    - `pattern`: String to replace in the source

    - `replace`: replacement String

    ###### Returns

    string with replaced elements

  - ### tokenizeString

    public static Vector tokenizeString(String source, char separator)

    Breaks a String to multiple strings.

    ###### Parameters

    - `source`: the String to break

    - `separator`: the pattern to search and break.

    ###### Returns

    a Vector of Strings

    ###### Deprecated

    use the tokenize() method instead

  - ### tokenizeString

    public static Vector tokenizeString(String source, String separator)

    Breaks a String to multiple strings (similar to string tokenizer)

    ###### Parameters

    - `source`: the String to break

    - `separator`: the characters that can be used to search and break.

    ###### Returns

    a Vector of Strings

    ###### Deprecated

    use the `java.lang.String)` method instead

  - ### tokenize

    public static List<String> tokenize(String source, char separator)

    Breaks a String to multiple strings.

    ###### Parameters

    - `source`: the String to break

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

    - `separator`: 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`: Objects to be converted to strings.

    - `delimiter`: The delimiter.

    ###### Returns

    The joined string.

    ###### Since

    8.0

  - ### join

    public static String join(Object[] strings, String delimiter)

    Joins a list or array of objects together using the specified delimiter.

    ###### Parameters

    - `strings`: Objects to be converted to strings.

    - `delimiter`: The delimiter.

    ###### Returns

    The joined string.

    ###### Since

    8.0

  - ### getBytes

    public static byte[] getBytes(String s)

    Helper to get bytes from string with UTF-8 encoding

    ###### Parameters

    - `s`: the string

    ###### Returns

    the bytes

  - ### newString

    public static String newString(byte[] b)

    Helper to get string from bytes with UTF-8 encoding

    ###### Parameters

    - `b`: 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`: the bytes

    - `offset`: the offset

    - `length`: the length

    ###### Returns

    the string