Package org.apache.commons.lang3
Class CharSequenceUtils
- java.lang.Object
-
- org.apache.commons.lang3.CharSequenceUtils
-
public class CharSequenceUtils extends java.lang.Object
Operations on
CharSequence
that arenull
safe.- Since:
- 3.0
- See Also:
CharSequence
-
-
Constructor Summary
Constructors Constructor Description CharSequenceUtils()
CharSequenceUtils
instances should NOT be constructed in standard programming.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.CharSequence
subSequence(java.lang.CharSequence cs, int start)
Returns a newCharSequence
that is a subsequence of this sequence starting with thechar
value at the specified index.static char[]
toCharArray(java.lang.CharSequence source)
Converts the given CharSequence to a char[].
-
-
-
Method Detail
-
subSequence
public static java.lang.CharSequence subSequence(java.lang.CharSequence cs, int start)
Returns a new
CharSequence
that is a subsequence of this sequence starting with thechar
value at the specified index.This provides the
CharSequence
equivalent toString.substring(int)
. The length (inchar
) of the returned sequence islength() - start
, so ifstart == end
then an empty sequence is returned.- Parameters:
cs
- the specified subsequence, null returns nullstart
- the start index, inclusive, valid- Returns:
- a new subsequence, may be null
- Throws:
java.lang.IndexOutOfBoundsException
- ifstart
is negative or ifstart
is greater thanlength()
-
toCharArray
public static char[] toCharArray(java.lang.CharSequence source)
Converts the given CharSequence to a char[].- Parameters:
source
- theCharSequence
to be processed.- Returns:
- the resulting char array, never null.
- Since:
- 3.11
-
-