public class TextUtils extends Object
String
and CharSequence
.Modifier and Type | Method and Description |
---|---|
static String |
join(boolean[] elements,
Object separator)
|
static String |
join(byte[] elements,
Object separator)
|
static String |
join(char[] elements,
Object separator)
|
static String |
join(double[] elements,
Object separator)
|
static String |
join(float[] elements,
Object separator)
|
static String |
join(int[] elements,
Object separator)
|
static String |
join(Iterable<?> iterable,
Object separator)
|
static String |
join(long[] elements,
Object separator)
|
static String |
join(Object[] elements,
Object separator)
|
static String |
join(short[] elements,
Object separator)
|
static String |
substring(String string,
int beginIndex,
int endIndex,
SurrogatePairPolicy policy)
|
static String |
substring(String string,
int beginIndex,
int endIndex,
SurrogatePairPolicy beginPolicy,
SurrogatePairPolicy endPolicy)
Returns a new
String that is a substring of string ,
from beginIndex (inclusive) to endIndex (exclusive). |
static String |
substring(String string,
int beginIndex,
SurrogatePairPolicy policy)
Returns a new
String that is a substring of string ,
from beginIndex (inclusive) to the end of string . |
public static String substring(String string, int beginIndex, SurrogatePairPolicy policy)
String
that is a substring of string
,
from beginIndex
(inclusive) to the end of string
.
The difference between this method and String.substring(int)
is
that this method allows you to specify a SurrogatePairPolicy
to
determine how a surrogate pair should be handled if the pair would
normally be split.
string
- the String
to create a substring frombeginIndex
- the beginning index (inclusive)policy
- the SurrogatePairPolicy
to use if a surrogate
pair would normally be splitstring
, beginning at beginIndex
,
unless changed by policy
IllegalArgumentException
- if string
or policy
is
null
, or beginIndex
is negative or greater than the
length of string
public static String substring(String string, int beginIndex, int endIndex, SurrogatePairPolicy beginPolicy, SurrogatePairPolicy endPolicy)
String
that is a substring of string
,
from beginIndex
(inclusive) to endIndex
(exclusive).
The difference between this method and
String.substring(int, int)
is that this method allows you to
specify a SurrogatePairPolicy
to determine how a surrogate pair
should be handled if the pair would normally be split at either the
beginIndex
or endIndex
.
string
- the String
to create a substring frombeginIndex
- the beginning index (inclusive)endIndex
- the ending index (exclusive)beginPolicy
- the SurrogatePairPolicy
to use if a surrogate
pair would normally be split at the beginIndex
endPolicy
- the SurrogatePairPolicy
to use if a surrogate
pair would normally be split at the endIndex
string
, from beginIndex
to
endIndex
, unless changed by either beginPolicy
or
endPolicy
IllegalArgumentException
- if string
,
beginPolicy
, or endPolicy
is null
,
beginIndex
is negative, endIndex
is greater than the
length of string
, or beginIndex
is greater than
endIndex
public static String substring(String string, int beginIndex, int endIndex, SurrogatePairPolicy policy)
String
that is a substring of the specified
String
, from beginIndex
(inclusive) to endIndex
(exclusive).
The difference between this method and
String.substring(int, int)
is that this method allows you to
specify a SurrogatePairPolicy
to determine how a surrogate pair
should be handled if the pair would normally be split.
string
- the String
to create a substring frombeginIndex
- the beginning index (inclusive)endIndex
- the ending index (exclusive)policy
- the SurrogatePairPolicy
to use if a surrogate
pair would normally be splitString
, from
beginIndex
to endIndex
, unless changed by the specified
SurrogatePairPolicy
IllegalArgumentException
- if string
or policy
is
null
, beginIndex
is negative, endIndex
is
greater than the length of string
, or beginIndex
is
greater than endIndex
public static String join(Iterable<?> iterable, Object separator)
String
of the elements of iterable
joined
together by separator
. The separator
and each element
will use Object.toString()
for its text. If separator
is null
, the elements will be joined together with no
separator. If any element is null
, "null"
will be used.iterable
- the elements to joinseparator
- the Object
to join the elements withString
IllegalArgumentException
- if iterable
is null
public static String join(Object[] elements, Object separator)
String
of the elements of elements
joined
together by separator
. The separator
and each element
will use Object.toString()
for its text. If separator
is null
, the elements will be joined together with no
separator. If any element is null
, "null"
will be used.elements
- the elements to joinseparator
- the Object
to join the elements withString
IllegalArgumentException
- if elements
is null
public static String join(byte[] elements, Object separator)
String
of each element of elements
joined
together by separator
. The separator
will use
Object.toString()
for the separator text. If separator
is null
, the elements will be joined together with no separator.elements
- the elements to joinseparator
- the Object
to join the elements withString
IllegalArgumentException
- if elements
is null
public static String join(short[] elements, Object separator)
String
of each element of elements
joined
together by separator
. The separator
will use
Object.toString()
for the separator text. If separator
is null
, the elements will be joined together with no separator.elements
- the elements to joinseparator
- the Object
to join the elements withString
IllegalArgumentException
- if elements
is null
public static String join(int[] elements, Object separator)
String
of each element of elements
joined
together by separator
. The separator
will use
Object.toString()
for the separator text. If separator
is null
, the elements will be joined together with no separator.elements
- the elements to joinseparator
- the Object
to join the elements withString
IllegalArgumentException
- if elements
is null
public static String join(long[] elements, Object separator)
String
of each element of elements
joined
together by separator
. The separator
will use
Object.toString()
for the separator text. If separator
is null
, the elements will be joined together with no separator.elements
- the elements to joinseparator
- the Object
to join the elements withString
IllegalArgumentException
- if elements
is null
public static String join(float[] elements, Object separator)
String
of each element of elements
joined
together by separator
. The separator
will use
Object.toString()
for the separator text. If separator
is null
, the elements will be joined together with no separator.elements
- the elements to joinseparator
- the Object
to join the elements withString
IllegalArgumentException
- if elements
is null
public static String join(double[] elements, Object separator)
String
of each element of elements
joined
together by separator
. The separator
will use
Object.toString()
for the separator text. If separator
is null
, the elements will be joined together with no separator.elements
- the elements to joinseparator
- the Object
to join the elements withString
IllegalArgumentException
- if elements
is null
public static String join(char[] elements, Object separator)
String
of each element of elements
joined
together by separator
. The separator
will use
Object.toString()
for the separator text. If separator
is null
, the elements will be joined together with no separator.elements
- the elements to joinseparator
- the Object
to join the elements withString
IllegalArgumentException
- if elements
is null
public static String join(boolean[] elements, Object separator)
String
of each element of elements
joined
together by separator
. The separator
will use
Object.toString()
for the separator text. If separator
is null
, the elements will be joined together with no separator.elements
- the elements to joinseparator
- the Object
to join the elements withString
IllegalArgumentException
- if elements
is null
Copyright © 2022 Frostphyr. All rights reserved.