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 getWithMK(String str) {
    if (TextUtils.isEmpty(str))
        return null;
    int index = str.indexOf("@mk");
    if (index == -1)
        return str + "@mk";
    return str.substring(0, index + 3);
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static String getWithoutMK(String str) {
    if (TextUtils.isEmpty(str))
        return null;
    int index = str.indexOf("@mk");
    if (index == -1)
        return str;
    return str.substring(0, index);
}

From source file:Main.java

/** convert bitrate To String*/
public static String bitrateToString(int nBitr) {

    String s;/*from w w w.j  a  va  2 s  . c om*/
    nBitr /= 1024;
    if (nBitr < 1024) {
        s = Integer.toString(nBitr) + "k";
    } else {
        String str = Float.toString(nBitr / 1024.0f);
        int n = str.indexOf('.');
        if (n >= 0 && n < str.length() - 2)
            str = str.substring(0, n + 2);

        s = (str + "m");
    }
    return s;
}

From source file:com.doculibre.constellio.utils.OSUtils.java

public static boolean isWindows64() {
    boolean windows64;
    if (SystemUtils.IS_OS_WINDOWS) {
        String osArch = System.getProperty("os.arch");
        if (osArch.indexOf("64") != -1) {
            windows64 = true;//from  w  w  w.  j  av  a  2 s  .  co  m
        } else {
            windows64 = false;
        }
    } else {
        windows64 = false;
    }
    return windows64;
}

From source file:mod.steamnsteel.item.SteamNSteelItem.java

public static String getUnwrappedUnlocalizedName(String unlocalizedName) {
    return unlocalizedName.substring(unlocalizedName.indexOf('.') + 1);
}

From source file:Main.java

public static Map<String, String> getUrlParams(String url) {
    Map<String, String> map = null;

    if (url != null && url.indexOf("&") > -1 && url.indexOf("=") > -1) {
        map = new HashMap<String, String>();

        String[] arrTemp = url.split("&");
        for (String str : arrTemp) {
            String[] qs = str.split("=");
            map.put(qs[0], qs[1]);/* w  ww  .j a v a  2 s . c  om*/
        }
    }
    return map;
}

From source file:Main.java

public static String ExtractBtw(String text, String sFrom, String sTo) {
    String result = "";
    int ifrom = text.indexOf(sFrom);
    if (ifrom != -1) {
        int ito = text.indexOf(sTo, ifrom + sFrom.length());
        if (ito != -1) {
            result = text.substring(ifrom + sFrom.length(), ito);
        }/*  w w w  .j  a  va2 s . co m*/
    }
    if (result == null)
        result = "";
    return result;
}