| java.lang.Object | |
| ↳ | java.lang.String |
An immutable sequence of characters/code units (chars). A
String is represented by array of UTF-16 values, such that
Unicode supplementary characters (code points) are stored/encoded as
surrogate pairs via Unicode code units (char)
| Constants | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
| Comparator<String> | CASE_INSENSITIVE_ORDER | ||||||||||
| Public Constructors | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Returns an empty string.
| |||||||||||
Converts the byte array to a String using the default encoding as
specified by the file.encoding system property.
| |||||||||||
This constructor is deprecated.
Use String(byte[]) or String(byte[], String) instead
| |||||||||||
Converts the byte array to a String using the default encoding as
specified by the file.encoding system property.
| |||||||||||
This constructor is deprecated.
Use String(byte[], int, int) instead
| |||||||||||
Converts the byte array to a String using the specified encoding.
| |||||||||||
Converts the byte array to a String using the specified encoding.
| |||||||||||
Initializes this String to contain the characters in the specified
character array.
| |||||||||||
Initializes this String to contain the specified characters in the
character array.
| |||||||||||
Creates a string that is a copy of another string
| |||||||||||
Creates a string from the contents of a StringBuffer.
| |||||||||||
Constructs a | |||||||||||
Constructs a | |||||||||||
| Public Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
Returns the character at the specified offset in this String.
| |||||||||||
Retrieves the Unicode code point value at the | |||||||||||
Retrieves the Unicode code point value that precedes the
| |||||||||||
Calculates the number of Unicode code points between
| |||||||||||
Compares the specified String to this String using the Unicode values of
the characters.
| |||||||||||
Compare the receiver to the specified String to determine the relative
ordering when the case of the characters is ignored.
| |||||||||||
Concatenates this String and the specified string.
| |||||||||||
Determines if this | |||||||||||
Returns whether the characters in the StringBuffer strbuf are the same as
those in this String.
| |||||||||||
Compares a | |||||||||||
Creates a new String containing the characters in the specified character
array.
| |||||||||||
Creates a new String containing the specified characters in the character
array.
| |||||||||||
Compares the specified string to this String to determine if the
specified string is a suffix.
| |||||||||||
Compares the specified object to this String and returns true if they are
equal.
| |||||||||||
Compares the specified String to this String ignoring the case of the
characters and returns true if they are equal.
| |||||||||||
Returns a printf-style formatted string, using the supplied format and
arguments.
| |||||||||||
Returns a printf-style formatted string, using the supplied format and
arguments, accordingly to the specified locale.
| |||||||||||
This method is deprecated.
Use getBytes() or getBytes(String)
| |||||||||||
Converts this String to a byte encoding using the default encoding as
specified by the file.encoding system property.
| |||||||||||
Converts this String to a byte encoding using the specified encoding.
| |||||||||||
Copies the specified characters in this String to the character array
starting at the specified offset in the character array.
| |||||||||||
Returns an integer hash code for the receiver.
| |||||||||||
Searches in this String for the index of the specified character.
| |||||||||||
Searches in this String for the first index of the specified character.
| |||||||||||
Searches in this String for the index of the specified string.
| |||||||||||
Searches in this String for the first index of the specified string.
| |||||||||||
Searches an internal table of strings for a string equal to this String.
| |||||||||||
Searches in this String for the last index of the specified character.
| |||||||||||
Searches in this String for the last index of the specified string.
| |||||||||||
Searches in this String for the index of the specified string.
| |||||||||||
Searches in this String for the index of the specified character.
| |||||||||||
Returns the size of this String.
| |||||||||||
Determines whether a this String matches a given regular expression.
| |||||||||||
Returns the index within this object that is offset from
| |||||||||||
Compares the specified string to this String and compares the specified
range of characters to determine if they are the same.
| |||||||||||
Compares the specified string to this String and compares the specified
range of characters to determine if they are the same.
| |||||||||||
Copies this String replacing occurrences of the specified character with
another character.
| |||||||||||
Copies this String replacing occurrences of the specified
target sequence with another sequence.
| |||||||||||
Replace any substrings within this String that match the supplied regular
expression expr, with the String substitute.
| |||||||||||
Replace the first substring within this String that matches the supplied regular
expression expr, with the String substitute.
| |||||||||||
Splits this String using the supplied regular expression expr.
| |||||||||||
Splits this String using the supplied regular expression expr.
| |||||||||||
Compares the specified string to this String, starting at the specified
offset, to determine if the specified string is a prefix.
| |||||||||||
Compares the specified string to this String to determine if the
specified string is a prefix.
| |||||||||||
Has the same result as the substring function, but is present so that
String may implement the CharSequence interface.
| |||||||||||
Copies a range of characters into a new String.
| |||||||||||
Copies a range of characters into a new String.
| |||||||||||
Copies the characters in this String to a character array.
| |||||||||||
Converts the characters in this String to lowercase, using the specified
Locale.
| |||||||||||
Converts the characters in this String to lowercase, using the default
Locale.
| |||||||||||
Returns a string containing a concise, human-readable description of the
receiver.
| |||||||||||
Converts the characters in this String to uppercase, using the specified
Locale.
| |||||||||||
Converts the characters in this String to uppercase, using the default
Locale.
| |||||||||||
Copies this String removing white space characters from the beginning and
end of the string.
| |||||||||||
Converts the specified float to its string representation.
| |||||||||||
Converts the specified boolean to its string representation.
| |||||||||||
Converts the specified double to its string representation.
| |||||||||||
Converts the specified character to its string representation.
| |||||||||||
Creates a new String containing the characters in the specified character
array.
| |||||||||||
Creates a new String containing the specified characters in the character
array.
| |||||||||||
Converts the specified long to its string representation.
| |||||||||||
Converts the specified integer to its string representation.
| |||||||||||
Converts the specified object to its string representation.
| |||||||||||
|
[Expand]
Inherited Methods | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|
From class java.lang.Object
| |||||||||||
From interface java.lang.CharSequence
| |||||||||||
From interface java.lang.Comparable
| |||||||||||
Returns an empty string.
Converts the byte array to a String using the default encoding as specified by the file.encoding system property. If the system property is not defined, the default encoding is ISO8859_1 (ISO-Latin-1). If 8859-1 is not available, an ASCII encoding is used.
| data | the byte array to convert to a String |
|---|
| NullPointerException | when data is null |
|---|
This constructor is deprecated.Use String(byte[]) or String(byte[], String) instead
Converts the byte array to a String, setting the high byte of every character to the specified value.
| data | the byte array to convert to a String |
|---|---|
| high | the high byte to use |
| NullPointerException | when data is null |
|---|
Converts the byte array to a String using the default encoding as specified by the file.encoding system property. If the system property is not defined, the default encoding is ISO8859_1 (ISO-Latin-1). If 8859-1 is not available, an ASCII encoding is used.
| data | the byte array to convert to a String |
|---|---|
| start | the starting offset in the byte array |
| length | the number of bytes to convert |
| IndexOutOfBoundsException | when length < 0, start < 0 or
start + length > data.length |
|---|---|
| NullPointerException | when data is null |
This constructor is deprecated.Use String(byte[], int, int) instead
Converts the byte array to a String, setting the high byte of every character to the specified value.
| data | the byte array to convert to a String |
|---|---|
| high | the high byte to use |
| start | the starting offset in the byte array |
| length | the number of bytes to convert |
| IndexOutOfBoundsException | when length < 0, start < 0 or
start + length > data.length |
|---|---|
| NullPointerException | when data is null |
Converts the byte array to a String using the specified encoding.
| data | the byte array to convert to a String |
|---|---|
| start | the starting offset in the byte array |
| length | the number of bytes to convert |
| encoding | the encoding |
| IndexOutOfBoundsException | when length < 0, start < 0 or
start + length > data.length |
|---|---|
| UnsupportedEncodingException | when encoding is not supported |
| NullPointerException | when data is null |
Converts the byte array to a String using the specified encoding.
| data | the byte array to convert to a String |
|---|---|
| encoding | the encoding |
| UnsupportedEncodingException | when encoding is not supported |
|---|---|
| NullPointerException | when data is null |
Initializes this String to contain the characters in the specified character array. Modifying the character array after creating the String has no effect on the String.
| data | the array of characters |
|---|
| NullPointerException | when data is null |
|---|
Initializes this String to contain the specified characters in the character array. Modifying the character array after creating the String has no effect on the String.
| data | the array of characters |
|---|---|
| start | the starting offset in the character array |
| length | the number of characters to use |
| IndexOutOfBoundsException | when length < 0, start < 0 or
start + length > data.length |
|---|---|
| NullPointerException | when data is null |
Creates a string that is a copy of another string
| string | the String to copy |
|---|
Creates a string from the contents of a StringBuffer.
| stringbuffer | the StringBuffer |
|---|
Constructs a String from the sub-array of Unicode code
points.
| codePoints | The array of Unicode code points to convert. |
|---|---|
| offset | The inclusive index into codePoints to begin
converting from. |
| count | The number of element in codePoints to copy. |
| NullPointerException | if codePoints is null. |
|---|---|
| IllegalArgumentException | if any of the elements of codePoints are not
valid Unicode code points. |
| IndexOutOfBoundsException | if offset or count are not
within the bounds of codePoints. |
Constructs a String from a StringBuilder.
| sb | The StringBuilder to copy from. |
|---|
| NullPointerException | if sb is null. |
|---|
Returns the character at the specified offset in this String.
| index | the zero-based index in this string |
|---|
| IndexOutOfBoundsException | when index < 0 or
index >= length()
|
|---|
Retrieves the Unicode code point value at the index.
| index | The index to the char code unit within this
object. |
|---|
| IndexOutOfBoundsException | if index is negative or greater than or equal
to length(). |
|---|
Retrieves the Unicode code point value that precedes the
index.
| index | The index to the char code unit within this
object. |
|---|
| IndexOutOfBoundsException | if index is less than 1 or greater than
length(). |
|---|
Calculates the number of Unicode code points between
beginIndex and endIndex.
| beginIndex | The inclusive beginning index of the subsequence. |
|---|---|
| endIndex | The exclusive end index of the subsequence. |
| IndexOutOfBoundsException | if beginIndex is negative or greater than
endIndex or endIndex is greater
than length(). |
|---|
Compares the specified String to this String using the Unicode values of the characters. Returns 0 if the strings contain the same characters in the same order. Returns a negative integer if the first non-equal character in this String has a Unicode value which is less than the Unicode value of the character at the same position in the specified string, or if this String is a prefix of the specified string. Returns a positive integer if the first non-equal character in this String has a Unicode value which is greater than the Unicode value of the character at the same position in the specified string, or if the specified String is a prefix of the this String.
| string | the string to compare |
|---|
| NullPointerException | when string is null |
|---|
Compare the receiver to the specified String to determine the relative ordering when the case of the characters is ignored.
| string | a String |
|---|
Concatenates this String and the specified string.
| string | the string to concatenate |
|---|
| NullPointerException | if string is null |
|---|
Determines if this String contains the sequence of
characters in the CharSequence passed.
| cs | The character sequence to search for. |
|---|
true if the sequence of characters are contained
in this object; otherwise falseReturns whether the characters in the StringBuffer strbuf are the same as those in this String.
| strbuf | the StringBuffer to compare this String to |
|---|
| NullPointerException | when strbuf is null |
|---|
Compares a CharSequence to this String to
determine if their contents are equal.
| cs | The character sequence to compare to. |
|---|
true if equal, otherwise falseCreates a new String containing the characters in the specified character array. Modifying the character array after creating the String has no effect on the String.
| data | the array of characters |
|---|
| NullPointerException | if data is null |
|---|
Creates a new String containing the specified characters in the character array. Modifying the character array after creating the String has no effect on the String.
| data | the array of characters |
|---|---|
| start | the starting offset in the character array |
| length | the number of characters to use |
| IndexOutOfBoundsException | if length < 0, start < 0 or
start + length > data.length |
|---|---|
| NullPointerException | if data is null |
Compares the specified string to this String to determine if the specified string is a suffix.
| suffix | the string to look for |
|---|
| NullPointerException | if suffix is null |
|---|
Compares the specified object to this String and returns true if they are equal. The object must be an instance of String with the same characters in the same order.
| object | the object to compare |
|---|
Compares the specified String to this String ignoring the case of the characters and returns true if they are equal.
| string | the string to compare |
|---|
Returns a printf-style formatted string, using the supplied format and
arguments. This function is a shortcut to
format(Locale.getDefault(), format, args).
| format | a format string |
|---|---|
| args | arguments to replace format specifiers, may be none |
| NullPointerException | if the format is null |
|---|---|
| IllegalArgumentException | if the format is invalid |
Returns a printf-style formatted string, using the supplied format and arguments, accordingly to the specified locale.
Note that this is a convenience method. Using it involves creating an internal Formatter instance on-the-fly, which is somewhat costly in terms of memory and time. This is probably acceptable if you use the method only rarely, but if you rely on it for formatting a large number of strings, consider creating and reusing your own Formatter instance instead.
| loc | the locale to apply; null value means no
localization |
|---|---|
| format | a format string |
| args | arguments to replace format specifiers, may be none |
| NullPointerException | if the format is null |
|---|---|
| IllegalArgumentException | if the format is invalid |
This method is deprecated.Use getBytes() or getBytes(String)
Converts this String to a byte array, ignoring the high order bits of each character.
| start | the starting offset of characters to copy |
|---|---|
| end | the ending offset of characters to copy |
| data | the destination byte array |
| index | the starting offset in the byte array |
| NullPointerException | when data is null |
|---|---|
| IndexOutOfBoundsException | when
start < 0, end > length(), index < 0, end - start > data.length - index |
Converts this String to a byte encoding using the default encoding as specified by the file.encoding system property. If the system property is not defined, the default encoding is ISO8859_1 (ISO-Latin-1). If 8859-1 is not available, an ASCII encoding is used.
Converts this String to a byte encoding using the specified encoding.
| encoding | the encoding |
|---|
| UnsupportedEncodingException | when the encoding is not supported |
|---|
Copies the specified characters in this String to the character array starting at the specified offset in the character array.
| start | the starting offset of characters to copy |
|---|---|
| end | the ending offset of characters to copy |
| buffer | the destination character array |
| index | the starting offset in the character array |
| IndexOutOfBoundsException | when start < 0, end > length(),
start > end, index < 0, end - start > buffer.length - index |
|---|---|
| NullPointerException | when buffer is null |
Returns an integer hash code for the receiver. Objects which are equal return the same value for this method.
Searches in this String for the index of the specified character. The search for the character starts at the specified offset and moves towards the end of this String.
| c | the character to find |
|---|---|
| start | the starting offset |
Searches in this String for the first index of the specified character. The search for the character starts at the beginning and moves towards the end of this String.
| c | the character to find |
|---|
Searches in this String for the index of the specified string. The search for the string starts at the specified offset and moves towards the end of this String.
| subString | the string to find |
|---|---|
| start | the starting offset |
| NullPointerException | when string is null |
|---|
Searches in this String for the first index of the specified string. The search for the string starts at the beginning and moves towards the end of this String.
| string | the string to find |
|---|
| NullPointerException | when string is null |
|---|
Searches an internal table of strings for a string equal to this String. If the string is not in the table, it is added. Returns the string contained in the table which is equal to this String. The same string object is always returned for strings which are equal.
Searches in this String for the last index of the specified character. The search for the character starts at the end and moves towards the beginning of this String.
| c | the character to find |
|---|
Searches in this String for the last index of the specified string. The search for the string starts at the end and moves towards the beginning of this String.
| string | the string to find |
|---|
| NullPointerException | when string is null |
|---|
Searches in this String for the index of the specified string. The search for the string starts at the specified offset and moves towards the beginning of this String.
| subString | the string to find |
|---|---|
| start | the starting offset |
| NullPointerException | when string is null |
|---|
Searches in this String for the index of the specified character. The search for the character starts at the specified offset and moves towards the beginning of this String.
| c | the character to find |
|---|---|
| start | the starting offset |
Returns the size of this String.
Determines whether a this String matches a given regular expression.
| expr | the regular expression to be matched |
|---|
| PatternSyntaxException | if the syntax of the supplied regular expression is not valid |
|---|---|
| NullPointerException | if expr is null |
Returns the index within this object that is offset from
index by codePointOffset code points.
| index | The index within this object to calculate the offset from. |
|---|---|
| codePointOffset | The number of code points to count. |
| IndexOutOfBoundsException | if index is negative or greater than
length() or if there aren't enough code points
before or after index to match
codePointOffset. |
|---|
Compares the specified string to this String and compares the specified range of characters to determine if they are the same.
| thisStart | the starting offset in this String |
|---|---|
| string | the string to compare |
| start | the starting offset in string |
| length | the number of characters to compare |
| NullPointerException | when string is null |
|---|
Compares the specified string to this String and compares the specified range of characters to determine if they are the same. When ignoreCase is true, the case of the characters is ignored during the comparison.
| ignoreCase | specifies if case should be ignored |
|---|---|
| thisStart | the starting offset in this String |
| string | the string to compare |
| start | the starting offset in string |
| length | the number of characters to compare |
| NullPointerException | when string is null |
|---|
Copies this String replacing occurrences of the specified character with another character.
| oldChar | the character to replace |
|---|---|
| newChar | the replacement character |
Copies this String replacing occurrences of the specified target sequence with another sequence. The string is processed from the beginning to the end.
| target | the sequence to replace |
|---|---|
| replacement | the replacement sequence |
| NullPointerException | if either of the arguments
is null
|
|---|
Replace any substrings within this String that match the supplied regular expression expr, with the String substitute.
| expr | the regular expression to match |
|---|---|
| substitute | the string to replace the matching substring with |
| NullPointerException | if expr is null |
|---|
Replace the first substring within this String that matches the supplied regular expression expr, with the String substitute.
| expr | the regular expression to match |
|---|---|
| substitute | the string to replace the matching substring with |
| NullPointerException | if expr is null |
|---|
Splits this String using the supplied regular expression expr. max controls the number of times that the pattern is applied to the string.
| expr | the regular expression used to divide the string |
|---|---|
| max | the number of times to apply the pattern |
| NullPointerException | if expr is null |
|---|
Splits this String using the supplied regular expression expr.
| expr | the regular expression used to divide the string |
|---|
| NullPointerException | if expr is null |
|---|
Compares the specified string to this String, starting at the specified offset, to determine if the specified string is a prefix.
| prefix | the string to look for |
|---|---|
| start | the starting offset |
| NullPointerException | when prefix is null |
|---|
Compares the specified string to this String to determine if the specified string is a prefix.
| prefix | the string to look for |
|---|
| NullPointerException | when prefix is null |
|---|
Has the same result as the substring function, but is present so that String may implement the CharSequence interface.
| start | the offset the first character |
|---|---|
| end | the offset of one past the last character to include |
| IndexOutOfBoundsException | when start or end is less than zero, start is greater than end, or end is greater than the length of the String. |
|---|
Copies a range of characters into a new String.
| start | the offset of the first character |
|---|---|
| end | the offset one past the last character |
| IndexOutOfBoundsException | when start < 0, start > end or
end > length()
|
|---|
Copies a range of characters into a new String.
| start | the offset of the first character |
|---|
| IndexOutOfBoundsException | when start < 0 or
start > length()
|
|---|
Copies the characters in this String to a character array.
Converts the characters in this String to lowercase, using the specified Locale.
| locale | the Locale |
|---|
Converts the characters in this String to lowercase, using the default Locale.
Returns a string containing a concise, human-readable description of the receiver.
Converts the characters in this String to uppercase, using the specified Locale.
| locale | the Locale |
|---|
Converts the characters in this String to uppercase, using the default Locale.
Copies this String removing white space characters from the beginning and end of the string.
<= \\u0020 removed
from the beginning and the end
Converts the specified float to its string representation.
| value | the float |
|---|
Converts the specified boolean to its string representation. When the
boolean is true return "true", otherwise return
"false".
| value | the boolean |
|---|
Converts the specified double to its string representation.
| value | the double |
|---|
Converts the specified character to its string representation.
| value | the character |
|---|
Creates a new String containing the characters in the specified character array. Modifying the character array after creating the String has no effect on the String.
| data | the array of characters |
|---|
| NullPointerException | when data is null |
|---|
Creates a new String containing the specified characters in the character array. Modifying the character array after creating the String has no effect on the String.
| data | the array of characters |
|---|---|
| start | the starting offset in the character array |
| length | the number of characters to use |
| IndexOutOfBoundsException | when length < 0, start < 0 or
start + length > data.length |
|---|---|
| NullPointerException | when data is null |
Converts the specified long to its string representation.
| value | the long |
|---|
Converts the specified integer to its string representation.
| value | the integer |
|---|
Converts the specified object to its string representation. If the object
is null return the string "null", otherwise use
toString() to get the string representation.
| value | the object |
|---|