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 getUrlFromUglyGoogleRedirect(String url) {
    if (url.startsWith("http://www.google.com/url?")) {
        url = url.substring("http://www.google.com/url?".length());
        String arr[] = urlDecode(url).split("\\&");
        for (String str : arr) {
            if (str.startsWith("q="))
                return str.substring("q=".length());
        }//  w  ww.  j av a2  s .  c o m
    }

    return null;
}

From source file:Main.java

public static int getColor(String colorHex) {
    if (!colorHex.startsWith("#"))
        colorHex = "#" + colorHex;
    int a;/*from www .ja  va2 s.co m*/
    int r;
    int g;
    int b;
    if (colorHex.length() == 7) {
        a = 0xFF;
        r = Integer.parseInt(colorHex.substring(1, 3), 16);
        g = Integer.parseInt(colorHex.substring(3, 5), 16);
        b = Integer.parseInt(colorHex.substring(5, 7), 16);
    } else if (colorHex.length() == 9) {
        a = Integer.parseInt(colorHex.substring(1, 3), 16);
        r = Integer.parseInt(colorHex.substring(3, 5), 16);
        g = Integer.parseInt(colorHex.substring(5, 7), 16);
        b = Integer.parseInt(colorHex.substring(7, 9), 16);
    } else
        return Color.BLACK;
    int c = Color.argb(a, r, g, b);
    return c;
}

From source file:Main.java

/**
 * Does the string reprsent an argument name as provided on the command line? Format: "--argname"
 * /*from  ww w  .j a  v a  2 s.co m*/
 * @param s
 *          Possible argument name
 * @return {@code true} if the string represents an argument name (is prefixed with ARG_PREFIX)
 */
private static boolean isArgName(String s) {
    return s != null && s.startsWith(ARG_PREFIX) && s.length() > ARG_PREFIX.length();
}

From source file:Main.java

public static String getUrlFromUglyGoogleRedirect(String url) {
    if (url.startsWith("https://www.google.com/url?")) {
        url = url.substring("https://www.google.com/url?".length());
        String arr[] = urlDecode(url).split("&");
        for (String str : arr) {
            if (str.startsWith("q="))
                return str.substring("q=".length());
        }/*  ww w  . jav  a  2  s .  c  om*/
    }

    return null;
}

From source file:Main.java

public static boolean isPhoto(@Nullable String mimeType) {
    return mimeType != null && mimeType.startsWith("image/");
}

From source file:Main.java

public static boolean isVideo(@Nullable String mimeType) {
    return mimeType != null && mimeType.startsWith("video/");
}

From source file:Main.java

/**
 * Determines if this is a quoted argumented - either single or
 * double quoted.// ww  w. ja v  a 2  s  .c o m
 *
 * @param argument the argument to check
 * @return true when the argument is quoted
 */
public static boolean isQuoted(final String argument) {
    return (argument.startsWith(SINGLE_QUOTE) || argument.startsWith(DOUBLE_QUOTE))
            && (argument.endsWith(SINGLE_QUOTE) || argument.endsWith(DOUBLE_QUOTE));
}

From source file:Main.java

/**
 * Get the string enclosed with quote./*from   w  ww  . j a v  a2  s  .c o  m*/
 * 
 * @param string
 * @return
 */
public static String addQuote(String string) {
    if (string != null && (!(string.startsWith("\"") && string.endsWith("\"")))) //$NON-NLS-1$//$NON-NLS-2$
    {
        return "\"" + string + "\""; //$NON-NLS-1$//$NON-NLS-2$
    }
    return string;
}

From source file:Main.java

public static boolean isTransferCategory(String category) {
    return !TextUtils.isEmpty(category) && category.startsWith("[") && category.endsWith("]");
}

From source file:Main.java

private static boolean isShortColorCode(String colorString) {
    return colorString.length() == 4 && colorString.startsWith("#") && isHexadecimalColor(colorString);
}