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
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static byte[]
    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
    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
    Modifier and Type
    Method
    Description
    protected Object
     
    boolean
    Indicates whether some other object is "equal to" this one.
    final Class
    Returns the runtime class of an object.
    int
    Returns a hash code value for the object.
    final void
    Wakes up a single thread that is waiting on this object's monitor.
    final void
    Wakes up all threads that are waiting on this object's monitor.
    Returns a string representation of the object.
    final void
    Causes current thread to wait until another thread invokes the method or the method for this object.
    final void
    wait(long timeout)
    Causes current thread to wait until either another thread invokes the method or the method for this object, or a specified amount of time has elapsed.
    final void
    wait(long timeout, int nanos)
    Causes current thread to wait until another thread invokes the method or the method for this object, or some other thread interrupts the current thread, or a certain amount of real time has elapsed.
  • 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: 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