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 boolean isTop(String str) {
    boolean flag = false;
    if (!TextUtils.isEmpty(str) && str.startsWith("#") && str.endsWith("#") && str.length() >= 2) {
        flag = true;//from   w w w.j  a  v a 2s . c o m
    }
    return flag;
}

From source file:com.vmware.identity.openidconnect.common.ScopeValue.java

private static boolean denotesResourceServer(String value) {
    return value.startsWith("rs_") && value.length() > ("rs_").length();
}

From source file:Main.java

public static List<String> extractUrl(String text) {
    String[] strings = text.split(" ");
    List<String> urls = new ArrayList<>();
    for (String s : strings) {
        if (isUrl(s)) {
            if (!s.startsWith("http")) {
                s = "http://" + s;
            }/*w  ww . j av  a2 s  .c  o  m*/
            urls.add(s);
        }
    }
    return urls;
}

From source file:Main.java

private static String removeSlashInStartAndAddAtTheEndOfBaseDir(String baseDir) {
    baseDir = baseDir.endsWith("/") ? baseDir : baseDir + "/";

    while (baseDir.startsWith("/") || baseDir.startsWith("./")) {
        baseDir = baseDir.startsWith("/") ? baseDir.substring(1) : baseDir;
        baseDir = baseDir.startsWith("./") ? baseDir.substring(2) : baseDir;
    }/*from  w ww. j  a  v  a2s .  co  m*/

    return baseDir;
}

From source file:Main.java

public static String perfectStart(String str, String attach) {
    if (str == null) {
        return attach;
    }/*from w w w  .  ja v  a  2s .  com*/
    return str.startsWith(attach) ? str : (attach + str);
}

From source file:Main.java

/**
 * Returns whether the current host's operating system is Mac OS.
 * /*w  w w .  j  a  va 2  s.  c  om*/
 * @return <code>true</code> if running on Mac OS, <code>false</code>
 *         otherwise.
 */
private static boolean isMacOS() {
    final String osName = System.getProperty("os.name", "").toLowerCase();
    return osName.startsWith("mac os");
}

From source file:Main.java

/**
 * Extracts a GTIN from a GS1-128 (Code 128) formatted bar code.
 *
 * @param code/*from   ww w.  ja va2s . c  om*/
 *         the raw bar code value
 * @return the extracted GTIN or null if none found
 */
public static String extractFromCode128(String code) {
    if (code.length() < 16) {
        return null;
    }
    if (code.startsWith("01") || code.startsWith("02")) {
        return code.substring(2, 16);
    }
    return null;
}

From source file:Main.java

/**
 * Get a uri's file path/*from   w w  w  . j a va2s . c  om*/
 * 
 * @param context the application context
 * @param uri     the uri to query
 * 
 * @return the file path
 */
public static String getUriPath(Context context, Uri uri) {
    String filePath = null;

    String scheme = uri.getScheme();

    if (scheme.startsWith("content")) {
        String[] projection = { MediaStore.Files.FileColumns.DATA };

        /* 
         * FIXME 2013-10-24 Tianzi Hou
         * 
         * we cannot get file path if it is from 
         *  content://com.google.android.gallery3d.provider
         * i.e. the Picasa service
         */
        filePath = null;
        Cursor cursor = context.getContentResolver().query(uri, projection, null, null, null);

        if (cursor != null) {
            int column_index = cursor.getColumnIndexOrThrow(projection[0]);
            cursor.moveToFirst();
            filePath = cursor.getString(column_index);
            cursor.close();
        }
    } else if (scheme.startsWith("file")) {
        filePath = uri.getPath();
    }

    return filePath;
}

From source file:Main.java

/**
 * Extracts a GTIN from a GS1 DataMatrix formatted bar code.
 *
 * @param code/*from   w  w w . j a  va  2 s .  com*/
 *         the raw bar code value
 * @return the extracted GTIN or null if none found
 */
public static String extractFromDataMatrix(String code) {
    if (code.length() < 16) {
        return null;
    }
    if (code.startsWith("01")) {
        return code.substring(2, 16);
    }
    return null;
}

From source file:Main.java

public static boolean hasArtRuntime() {
    final String vmVersion = System.getProperty("java.vm.version");
    return vmVersion != null && vmVersion.startsWith("2.");
}