Java Utililty Methods String Index Of

List of utility methods to do String Index Of

Description

The list of methods to do String Index Of are organized into topic(s).

Method

intindexOfWord(String word, String string)
returns the index (word count) of word in the string.
word = word.toLowerCase().trim();
String wordInString;
StringTokenizer st = new StringTokenizer(string);
for (int i = 0; st.hasMoreElements(); i++) {
    wordInString = st.nextToken().toLowerCase().trim();
    if (word.equals(wordInString))
        return i;
return -1;
booleanisPhaseGroupContainsPhase(int index, String phaseName)
This static method determines if a phase group referenced by its index contains specified phase.
return phaseGroupPhases.get(index).contains(phaseName);
intlastIndexOf(String pattern, String s)
last Index Of
if (!isNullOrEmpty(s)) {
    int pos = s.indexOf(pattern);
    while (pos != -1) {
        if ((pos + 1) >= s.length())
            return pos;
        int newPos = s.substring(pos + 1).indexOf(pattern);
        if (newPos > 0) {
            pos = newPos + 1 + pos;
...
intlastIndexOfIgnoreCase(final String s, final String subS)
last Index Of Ignore Case
return lastIndexOfIgnoreCase(s, subS, s.length(), 0);
StringmergeStringLines(String lineOne, String lineTwo, int keyIndex, int insertingIndex)
merge String Lines
String mergedLine = "";
String[] splittingLine = lineOne.split(",");
String lineTwoWOKey = removeColumn(lineTwo, keyIndex);
if (splittingLine.length <= insertingIndex)
    mergedLine = lineOne + "," + lineTwoWOKey;
else {
    mergedLine = getMergedLine(lineOne, lineTwoWOKey, insertingIndex);
return mergedLine;
ListreadColumn(int columnIndex, String inputString, String columnSeparator)
read Column
List<String> columnValues = new ArrayList<String>();
for (String line : inputString.split(System.getProperty("line.separator"))) {
    String[] columns = line.split(columnSeparator);
    if (columnIndex < columns.length) {
        columnValues.add(columns[columnIndex]);
return columnValues;
...
StringremoveColumn(String line, int index)
remove Column
ArrayList<String> splittingLine = new ArrayList<String>(Arrays.asList(line.split(",")));
splittingLine.remove(index);
return strArrayListToString(splittingLine);
String[]splitUsingIndexOf(String splittee, String splitter)
split Using Index Of
ArrayList<String> list = new ArrayList<String>();
splittee += " " + splitter;
int pos = 0, end;
while ((end = splittee.indexOf(splitter, pos)) >= 0) {
    list.add(splittee.substring(pos, end).trim());
    pos = end + 1;
String[] result = new String[list.size()];
...
Stringsub(String string, int fromIndex, int toIndex)
sub
int len = string.length();
if (fromIndex < 0) {
    fromIndex = len + fromIndex;
    if (toIndex == 0) {
        toIndex = len;
if (toIndex < 0) {
...
StringsubStringChinese(String str, int startIndex, int endIndex)
sub String Chinese
int length = 0;
int size = endIndex - startIndex;
List<Character> charList = new ArrayList<Character>();
for (char c : str.toCharArray()) {
    if (isChinese(c))
        length += 2;
    else
        length++;
...