Example usage for java.lang String indexOf

List of usage examples for java.lang String indexOf

Introduction

In this page you can find the example usage for java.lang String indexOf.

Prototype

public int indexOf(String str) 

Source Link

Document

Returns the index within this string of the first occurrence of the specified substring.

Usage

From source file:Main.java

public static String extractSubstring(String string, int n) {
    int index = string.indexOf("|");
    while (n > 0) {
        if (index == -1)
            return (n == 0 ? string : null);
        n--;//from www.j a v  a2  s .co m
        string = string.substring(index + 1);
        index = string.indexOf("|");
    }
    return (index == -1 ? string : string.substring(0, index));
}

From source file:Main.java

/**
 * _more_//  w  ww.  ja  v  a  2 s .  c  o  m
 *
 * @param tagName _more_
 *
 * @return _more_
 */
public static boolean isFullyQualified(String tagName) {
    return tagName.indexOf(":") >= 0;
}

From source file:Main.java

private static boolean isSymbian(String userAgent) {
    return userAgent.indexOf(SYMBIAN) != -1 || userAgent.indexOf(S60) != -1 || userAgent.indexOf(S70) != -1
            || userAgent.indexOf(S80) != -1 || userAgent.indexOf(S90) != -1;
}

From source file:Main.java

public static String getUserIdFromTagUid(final String uid) {
    final int start = uid.indexOf('/') + 1;
    final int end = uid.indexOf('/', start);
    return uid.substring(start, end);
}

From source file:Main.java

public static String getURL(String v) {

    int site = v.indexOf("http://");
    if (site >= 0) {
        int end = v.length();
        String chars = " \n\r\t";
        for (int c = 0; c < chars.length(); c++) {
            int r = v.indexOf(chars.charAt(c), site);
            if (r >= 0 && r < end) {
                end = r;/*from   w  w w .  j a  va  2  s  . com*/
            }
        }
        return v.substring(site, end);
    }
    return null;

}

From source file:Main.java

/**
 * from "myFunction(arg1,arg2)", return "myFunction"
 *///w ww  .ja  v  a2  s.c o m
public static String getFunctionName(String tag) {
    return tag.substring(0, tag.indexOf('(')).trim();
}

From source file:Main.java

public static String toSubpath(String pathName, String fileName) {
    return (fileName.indexOf(pathName) != -1)
            ? fileName.substring(fileName.indexOf(pathName) + pathName.length() + 1)
            : fileName;//from  w w w.  j ava  2 s.  c om
}

From source file:Main.java

public static String convertToUtf(String xml, String utf) {
    return utf + xml.substring(xml.indexOf("?>") + 2);
}

From source file:Main.java

public static String getRawPath(String path) {
    String rawPath = path.substring(0, path.indexOf("_tn"));
    return rawPath;
}

From source file:Main.java

public static String getArray(String arrNameFull) {
    return arrNameFull.substring(0, arrNameFull.indexOf("]") + 1);
}