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 quickTagContentEscape(String aString) {
    if (aString.indexOf('&') >= 0) {
        aString = removeAmpersand.matcher(aString).replaceAll("&");
    }/*from   w  ww  .  jav  a 2s . c om*/
    return escapeAngleBrackets(aString);
}

From source file:Main.java

/**
 * Times": "(1425956629171)" to timeInMillis
 * @param string//w w  w.ja v a 2 s.c om
 * @return
 */
public static long parseToTimeInMillis(String string) {
    int start = string.indexOf("(") + 1;
    int end = string.indexOf(")");
    String timeString = string.substring(start, end);

    long timeMillis = Long.parseLong(timeString);
    return timeMillis;
}

From source file:Main.java

public static int formatStrToIntTime(String time) {
    int colonLocation = time.indexOf(":");
    int minute = Integer.parseInt(time.substring(0, colonLocation));
    int second = Integer.parseInt(time.substring(colonLocation + 1));
    return formatToIntTime(minute, second);
}

From source file:Main.java

private static boolean isIpod(String userAgent) {
    return userAgent.indexOf(IPOD) != -1;
}

From source file:Main.java

private static boolean isIpad(String userAgent) {
    return userAgent.indexOf(IPAD) != -1;
}

From source file:Main.java

public static boolean isEmail(String input) {
    int atIndex = input.indexOf('@');

    if (atIndex == -1)
        return false;

    int lastDotIndex = input.lastIndexOf('.');

    return atIndex < lastDotIndex && lastDotIndex - atIndex != 1 && lastDotIndex != input.length() - 1
            && atIndex != 0;//w ww.j ava  2  s  .  c  o  m
}

From source file:Main.java

public static String getNickname(String account) {
    return account.substring(0, account.indexOf("@"));
}

From source file:Main.java

public static boolean isArrayType(String typeName) {
    return typeName.indexOf("[]") >= 0;

}

From source file:Main.java

public static String escapeAngleBrackets(String aString) {
    if (aString.indexOf('<') >= 0) {
        aString = removeLeftAngleBracket.matcher(aString).replaceAll("&lt;");
    }// ww w .ja v  a 2  s .c  o m
    if (aString.indexOf('>') >= 0) {
        aString = removeRightAngleBracket.matcher(aString).replaceAll("&gt;");
    }
    return aString;
}

From source file:Main.java

/**
 * Elimina la cabecera de un documento XML.
 *//*  ww w.j a  va 2 s  .c om*/
public static String eliminaCabecera(String documento) {
    if (documento.indexOf("<?xml version=") == 0)
        return documento.substring(documento.indexOf("?>") + 2); // +2 por el '?>' de la cabecera
    return documento;
}