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

/**
 * Checks wether the specified path expression is an absolute path.
 *
 * @param path the path expression.// ww w .j a v a2  s . c om
 * @return <code>true</code> if specified path expression is an absolute
 * path, otherwise <code>false</code>.
 */
public static boolean isAbsolutePath(String path) {
    return path != null && (path.startsWith("/") || path.startsWith(INSTANCE_FUNCTION));
}

From source file:Main.java

public static String getPureTel(String tel) {
    if (null == tel) {
        return tel;
    }//from  w  ww  . ja v  a  2 s  .  c  o  m
    String pureTel = tel.trim();
    if (pureTel.startsWith(INTERNATION_PREFIX)) {
        pureTel = pureTel.substring(INTERNATION_PREFIX.length());
    }
    if (pureTel.startsWith(COMMON_PREFIX)) {
        pureTel = pureTel.substring(COMMON_PREFIX.length());
    }
    return pureTel.replaceAll("[\\D]", "");
}

From source file:Main.java

/**
 * Removes the "file://" prefix from the given URI string, if applicable.
 * If the given URI string doesn't have a "file://" prefix, it is returned unchanged.
 *
 * @param uriString the URI string to operate on
 * @return a path without the "file://" prefix
 *//*from w  w w. java 2  s  .c o m*/
public static String stripFileProtocol(String uriString) {
    if (uriString.startsWith("file://")) {
        uriString = uriString.substring(7);
    }
    return uriString;
}

From source file:Main.java

public static boolean isURL(String url) {

    if (url.startsWith("http://") || url.startsWith("https://")) {
        return true;
    }// ww w .j  a v a2s .  com

    return false;
}

From source file:Main.java

private static String getFormulaName(String expression) {
    if (expression.startsWith("Total.sum")) {
        return "=SUM";
    } else if (expression.startsWith("Total.ave")) {
        return "=AVERAGE";
    } else if (expression.startsWith("Total.max")) {
        return "=MAX";
    } else if (expression.startsWith("Total.min")) {
        return "=MIN";
    } else if (expression.startsWith("Total.count")) {
        return "=COUNT";
    }/*from  w ww. j a va  2s  .  c o m*/
    throw new RuntimeException("Cannot parse the expression" + expression);
}

From source file:Utils.java

public static String stripCDATA(String s) {
    s = s.trim();/*from w w  w . j a  va  2 s .c o  m*/
    if (s.startsWith("<![CDATA[")) {
        s = s.substring(9);
        int i = s.indexOf("]]&gt;");
        if (i == -1) {
            throw new IllegalStateException("argument starts with <![CDATA[ but cannot find pairing ]]&gt;");
        }
        s = s.substring(0, i);
    }
    return s;
}

From source file:Main.java

public static boolean isHuaweiPhone() {
    String systemModel = android.os.Build.MODEL;
    if (systemModel.startsWith("HUAWEI") || systemModel.startsWith("huawei")) {
        return true;
    }/*from w w  w  .  j a  v  a2  s.  c  o m*/
    return false;
}

From source file:Main.java

public static String getUrlFromUglyFacebookRedirect(String url) {
    if (url.startsWith("https://www.facebook.com/l.php?u=")) {
        url = url.substring("https://www.facebook.com/l.php?u=".length());
        return urlDecode(url);
    }// w w w .j av  a  2  s  . com

    return null;
}

From source file:Main.java

public static boolean isValidNodePath(String path) {
    return path != null && path.startsWith("/") && !path.contains("//") && !path.contains("*")
            && !path.contains("(") && !path.contains(")");
}

From source file:Main.java

public static String getUrlFromUglyFacebookRedirect(String url) {
    if (url.startsWith("http://www.facebook.com/l.php?u=")) {
        url = url.substring("http://www.facebook.com/l.php?u=".length());
        return urlDecode(url);
    }// w ww.  j  a  v  a  2 s  .  c  o m

    return null;
}