public class Text extends Object
| Constructor | Description |
|---|---|
Text() |
|
Text(String newText) |
Constructs the class with the given String
|
| Modifier and Type | Method | Description |
|---|---|---|
int |
indexOf(String searchText) |
Returns the index within this string of the first occurrence of the
specified substring.
|
int |
indexOf(String searchText,
int fromIndex) |
Returns the index within this string of the first occurrence of the
specified substring, starting at the specified index.
|
int |
occuranceNo(String searchText) |
searches the gievn text and returns the number of occurances
|
void |
replace(String oldText,
String newText) |
replaces the provided new text with the old text, the operation will take
place on the first occurance for the old text
|
void |
replace(String oldText,
String newText,
int fromIndex) |
replaces the provided new text with the old text, the operation will take
place on the first occurance for the old text after the given index
|
int |
replaceAll(String oldText,
String newText) |
replaces the provided new text with every occurance for the old text
|
void |
setText(String Text) |
|
String |
toString() |
returns the text after processing
|
public Text(String newText)
public Text()
public void setText(String Text)
public int indexOf(String searchText)
isthis.startsWith(str, <i>k</i>)
true.str - any string.-1
is returned.NullPointerException - if str is null.public int indexOf(String searchText, int fromIndex)
isthis.startsWith(str, <i>k</i>) && (<i>k</i> >= fromIndex)
true.
There is no restriction on the value of fromIndex. If it
is negative, it has the same effect as if it were zero: this entire
string may be searched. If it is greater than the length of this string,
it has the same effect as if it were equal to the length of this string:
-1 is returned.
str - the substring to search for.fromIndex - the index to start the search from.fromIndex,
then the index of the first character of the first such substring
is returned. If it does not occur as a substring starting at
fromIndex or beyond, -1 is
returned.NullPointerException - if str is nullpublic void replace(String oldText, String newText, int fromIndex)
oldText - The old text to be replacednewText - The new textfromIndex - The starting positionNullPointerException - if either texts are nullpublic void replace(String oldText, String newText)
oldText - The old text to be replacednewText - The new textNullPointerException - if either texts are nullpublic int replaceAll(String oldText, String newText)
oldText - The old text to be replacednewText - The new textNullPointerException - if either texts are nullpublic int occuranceNo(String searchText)
searchText - The text to search forNullPointerException - if searchTexts is nullCopyright © 2019 SMYLD. All rights reserved.