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 b64FileName(String fn) {
    String fln = fn.substring(fn.lastIndexOf('/') + 1);
    fln = fln.substring(0, fln.indexOf('.'));
    return fln + B64EX;
}

From source file:Main.java

private static String getNodeText(String name, String str) {
    String b = "<" + name + ">";
    return str.substring(str.indexOf(b) + b.length(), str.indexOf("</" + getName(name) + ">")).trim();
}

From source file:Main.java

static public String strXmlCleanup(String str) {
    if (str == null)
        return "";

    if (str.indexOf("&#") != -1) {
        str = str.replaceAll(//from w w w  .  j  a va2s.c  om
                "&#(0|1|2|3|4|5|6|7|8|11|12|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31);", " ");
    }
    return str;
}

From source file:Main.java

public static boolean isWindows() {
    String os = System.getProperty("os.name").toLowerCase();
    return (os.indexOf("win") >= 0);
}

From source file:Main.java

public static String getDueDateString(String itemText) {
    String dateString = null;/*from  www.  ja v a 2  s .  c om*/
    int startIndex = itemText.indexOf("[");
    int endIndex = itemText.indexOf("]");
    if (startIndex != -1 && endIndex != -1)
        dateString = itemText.substring(startIndex + 1, endIndex);

    return dateString;
}

From source file:Main.java

public static String parsePersonSkillXML(String xmlString) {
    String personSkill = "";
    int jishustart = xmlString.indexOf("<ArchivementDetail>") + 19;
    int jishusend = xmlString.indexOf("</ArchivementDetail>");

    personSkill = xmlString.substring(jishustart, jishusend);

    return personSkill;
}

From source file:Main.java

private static String getShortName(String uri) {
    int scolon = uri.indexOf(SEMICOLON);
    int slash;//from   w w  w.j  ava 2 s .  com
    if (scolon != -1) {
        slash = uri.lastIndexOf(SEPARATOR, scolon);
    } else {
        slash = uri.lastIndexOf(SEPARATOR);
    }
    String shortName = null;
    if (scolon == -1) {
        shortName = uri.substring(slash + 1);
    }
    if (slash < scolon) {
        shortName = uri.substring(slash + 1, scolon);
    }
    if (shortName != null && shortName.length() > COUNTER_NAME_LIMIT) {
        shortName = shortName.substring(shortName.length() - COUNTER_NAME_LIMIT);
    }
    return shortName;
}

From source file:Main.java

private static boolean isValidCategory(String category) {
    return category == null
            || (category.indexOf(CATEGORY_SEPARATOR) < 0 && category.indexOf(LEAF_SEPARATOR) < 0);
}

From source file:Main.java

public static boolean containStr(String totalStr, String destStr) {
    if (totalStr != null)
        return totalStr.indexOf(destStr) >= 0;

    return false;
}

From source file:Main.java

public static String convertDate(String date1) {
    try {/*  www  . j  a  v a2s .  c o m*/
        String date = date1.substring(0, date1.indexOf(" "));
        String year = date.substring(0, 4);
        String month = date.substring(5, 7);
        String day = date.substring(8, 10);
        return day + "/" + month + "/" + year;
    } catch (Exception e) {
        return date1;
    }
}