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 getNode(String plain, String nodename) {
    if (plain.indexOf("<" + nodename + ">") < 0)
        return "";
    return plain.substring(plain.indexOf("<" + nodename + ">") + nodename.length() + 2,
            plain.indexOf("</" + nodename + ">"));
}

From source file:Main.java

private static String classSimpleName(String stackLine) {
    int index1 = stackLine.indexOf('(');
    int index2 = stackLine.indexOf(')');
    if (index1 >= 0 && index2 >= 0) {
        return stackLine.substring(index1 + 1, index2);
    }//from w w w  .  j  a  va  2  s .  co  m
    return stackLine;
}

From source file:Main.java

private static int getQueryIndex(String homeUrl) {
    return homeUrl.indexOf("?"); //$NON-NLS-1$
}

From source file:Main.java

public static String normalizeName(String name) {

    String resp = name.trim();
    while (resp.indexOf("  ") != -1) {
        resp = resp.replace("  ", " ");
    }/*from w  w  w  .  j  a  v a2s .  co  m*/
    return resp;
}

From source file:Main.java

public static String convertGSAtoUri(String appId) {
    int index = appId.indexOf("/http/");
    return "http://" + appId.substring(index + 6);
}

From source file:Main.java

public static String parseNick(String text) {

    int first = text.indexOf("<");
    int last = text.indexOf(">");
    if (first == -1 || last == -1) {
        return null;
    }//w ww  .  j  a  v a 2 s . c o m

    String nick = text.substring(text.indexOf("<") + 1, last);
    return nick;
}

From source file:Main.java

/**
 * Extract root url from Capi header// w w  w  .  j  av a  2s .  c om
 * @param link
 * @return a String containing url
 */
private static String extractRootUrl(String link) {
    return link.substring(link.indexOf('<') + 1, link.indexOf('>'));
}

From source file:Main.java

public static String getIdForCacheKey(String cacheKey) {
    return cacheKey.substring(cacheKey.indexOf('_') + 1);
}

From source file:Utils.java

/**
 * @param hostStr/*  ww  w .j  a v a  2 s. c  o  m*/
 * @return
 */
static public String parseHost(String hostStr) {
    int sepIdx = hostStr.indexOf(':');
    if (sepIdx < 0) {
        return hostStr;
    } else {
        return hostStr.substring(0, sepIdx);
    }
}

From source file:Main.java

private static long readThreadAddres(String line) {
    int start = line.indexOf("0x"); //$NON-NLS-1$
    if (start < 0)
        return -1;
    return (new BigInteger(line.substring(start + 2), 16)).longValue();
}