Example usage for java.lang String startsWith

List of usage examples for java.lang String startsWith

Introduction

In this page you can find the example usage for java.lang String startsWith.

Prototype

public boolean startsWith(String prefix) 

Source Link

Document

Tests if this string starts with the specified prefix.

Usage

From source file:Main.java

public static String prependProtocol(String s) {
    if (!TextUtils.isEmpty(s) && !s.startsWith("http:") && !s.startsWith("https:"))
        s = (new StringBuilder("https:")).append(s).toString();
    return s;//from   w ww .  j  av a  2  s  . c o m
}

From source file:Main.java

/**
 * @param xml//ww  w .j  ava 2s. co m
 */
public static String removeXmlDecl(String xml) {
    if (xml.startsWith("<?xml")) {
        xml = xml.substring(xml.indexOf("<", 1));
    }
    return xml;
}

From source file:Main.java

public static boolean isChinaMobile(String mobile) {
    if (mobile.startsWith("1349")) {
        return false;
    }//from  w w w .j  a  v a2 s.c  om
    return (mobile.startsWith("134") || mobile.startsWith("135") || mobile.startsWith("136")
            || mobile.startsWith("137") || mobile.startsWith("138") || mobile.startsWith("139")
            || mobile.startsWith("150") || mobile.startsWith("151") || mobile.startsWith("157")
            || mobile.startsWith("158") || mobile.startsWith("159") || mobile.startsWith("188"));
}

From source file:com.facebook.util.StringUtils.java

public static String stripQuotes(String input) {
    if (input.startsWith("'") || input.startsWith("\"")) {
        return StringEscapeUtils.unescapeJava(input.substring(1, input.length() - 1));
    } else {// w w  w  .  j a  v a  2s.  c  o  m
        return input;
    }
}

From source file:Main.java

/**
 * @return true if the MimeType type is image
 *///from  ww  w.  j  a v  a2  s  . co m
public static boolean isImageMimeType(String mimeType) {
    return mimeType != null && mimeType.startsWith("image/");
}

From source file:Main.java

public static String makeItUrl(String str) {//TODO move
    if (!str.startsWith(HTTP)) {
        if (str.contains(HTTP)) {
            str = str.substring(str.indexOf(HTTP)).replace("\"", "").replace("\\", "").replace("]", "");//1202 0304 
        } else {//from   w w  w. ja va2 s .  c o  m
            Log.e("jackUtil", "url illegal:" + str);
            str = "";
        }
    }
    return str;
}

From source file:Main.java

/**
 * Creates a file Uri for a file defined by its absolute path.
 * The method can handle the case of an absolute path (e.g. /data/data....)
 * and a Uri path containing the file:// scheme (e.g. file:///data/data...)
 *//*w w w .j  a  v a 2s. c om*/
public static Uri createFileUri(String path) {
    if (path.startsWith("file://")) {
        return Uri.parse(path);
    }
    return Uri.fromFile(new File(path));
}

From source file:Main.java

private static String combineInternal(String path1, String path2) {
    if (path1.endsWith("/") && path2.startsWith("/")) {
        return path1 + path2.substring(1, path2.length());
    } else {/*from w  w w. j  av a  2 s  . c  o m*/
        return path1 + path2;
    }
}

From source file:Main.java

public static String getter2property(String methodName) {
    if (methodName.startsWith("get") && methodName.length() > 3) {
        return Character.toLowerCase(methodName.charAt(3)) + methodName.substring(4);
    }/*from  w w w .  ja va  2  s. c  o m*/
    if (methodName.startsWith("is") && methodName.length() > 2) {
        return Character.toLowerCase(methodName.charAt(2)) + methodName.substring(3);
    }
    return null;
}

From source file:Main.java

/**
 * This function filters the input collection and returns a collection of elements starting with specified input.   
 * @param coll//from w  ww .ja va  2 s. c o m
 * @param str
 * @return Filtered Collection<String>
 */
public static Collection<String> startsWithString(Collection<String> coll, final String str) {
    Collection<String> list = new ArrayList<String>();
    for (String item : coll) {
        if (item.startsWith(str)) {
            list.add(item);
        }
    }
    return list;
}