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 cleanAvatarPath(String path) {
    String avatarPath;//from  www .  ja v  a2 s .  c om
    try {
        avatarPath = path.substring(0, path.indexOf("?"));
    } catch (Exception e) {
        avatarPath = "Failure on clear avatar path";
    }
    return avatarPath;
}

From source file:Main.java

public static int delimiterOffset(String input, int pos, int limit, String delimiters) {
    for (int i = pos; i < limit; i++) {
        if (delimiters.indexOf(input.charAt(i)) != -1)
            return i;
    }/*from w  w w  .  ja va 2  s  . c o m*/
    return limit;
}

From source file:Main.java

public static String getHostFromUrl(String url) {
    if (url.contains(COLON)) {
        return url.substring(0, url.indexOf(COLON));
    } else {/*ww w  .  ja  va2s .  c o m*/
        return url;
    }
}

From source file:Main.java

/**
 * Convert CR or CR+LF line breaks to LF line breaks.
 * @see http://en.wikipedia.org/wiki/Newline
 * @param input may contain any mix of newline sequences
 * @returns null if passed null, identical string in nominal case, or string with only \n for newline.
 *///  ww w  . j  a  v  a  2s  .  co  m
public static String convertNewlinesToLinefeeds(String input) {
    if (input == null)
        return null;
    if (input.indexOf('\r') < 0)
        return input; // optimization
    return input.replace("\r\n", "\n").replace("\r", "\n");
}

From source file:Main.java

private static String getProgramName() {
    String p = System.getProperty("program");
    if (p != null)
        return p;

    String cp = System.getProperty("java.class.path");
    if (cp.indexOf(File.pathSeparator) == -1) {
        File f = new File(cp);
        if (f.getName().equals("jtreg.jar"))
            return "java -jar jtreg.jar ";
    }// ww  w . j ava2 s.  c  om

    return "java " + Main.class.getName();
}

From source file:com.hangum.tadpole.rdb.core.editors.objects.table.TbUtils.java

/** is insert column */
public static boolean isInsert(String value) {
    return value.indexOf("INSERT") != -1; //$NON-NLS-1$
}

From source file:com.hangum.tadpole.rdb.core.editors.objects.table.TbUtils.java

/** is update column */
public static boolean isUpdate(String value) {
    return value.indexOf("UPDATE") != -1; //$NON-NLS-1$
}

From source file:com.hangum.tadpole.rdb.core.editors.objects.table.TbUtils.java

/** is delete column */
public static boolean isDelete(String value) {
    return value.indexOf("DELETE") != -1; //$NON-NLS-1$
}

From source file:com.hangum.tadpole.rdb.core.editors.objects.table.TbUtils.java

/** is modify data */
public static boolean isModifyData(String value) {
    return value.indexOf("<em style='color:rgb") != -1; //$NON-NLS-1$
}

From source file:Main.java

/**
 * Turn a string into a note's title and text
 * @param value/*w  w  w  . j a v  a  2 s. c  o m*/
 * @return
 */
@SuppressWarnings("nls")
public static String[] fromNoteField(String value) {
    String[] result = new String[2];
    int firstLineBreak = value.indexOf('\n');
    if (firstLineBreak > -1 && firstLineBreak + 1 < value.length()) {
        result[0] = value.substring(0, firstLineBreak);
        result[1] = value.substring(firstLineBreak + 1, value.length());
    } else {
        result[0] = "";
        result[1] = value;
    }
    return result;
}