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

/**
 * check whether the bssid is belong to ESP device
 * /*from   w  ww  .j  a va2s .c  o  m*/
 * @param BSSID the bssid to be checked
 * @return whether the bssid is belong to ESP device
 */
public static boolean isEspDevice(String BSSID) {
    // ESP wifi's sta bssid is started with "18:fe:34"
    return BSSID != null && (BSSID.startsWith("18:fe:34"));
}

From source file:Main.java

public static String formatPhone(String phoneNumber) {
    if (phoneNumber == null) {
        return "";
    }// www .  j  av a 2 s  .  c o  m
    if (phoneNumber.startsWith(PHONE_PREFIX)) {
        return phoneNumber.substring(PHONE_PREFIX.length()).trim();
    }
    return phoneNumber.trim();
}

From source file:Main.java

public static boolean validRecordTable(String table) {
    if (null == table) {
        return false;
    } else {//from w  w  w  .  j a  va 2  s.c om
        return table.startsWith(RECORD_TABLE_PREFIX);
    }
}

From source file:net.sf.zekr.common.util.PathUtils.java

public static boolean isOnlineContent(String fileName) {
    return fileName.startsWith("http://") || fileName.startsWith("https://") || fileName.startsWith("ftp://");
}

From source file:Main.java

/**
 * @param urlForDomain// w w  w.ja  v a 2s  . c  om
 *            extract the domain from this url
 * @param path
 *            this url does not have a domain
 * @return
 */
public static String useDomainOfFirstArg4Second(String urlForDomain, String path) {
    if (path.startsWith("http"))
        return path;

    if ("favicon.ico".equals(path))
        path = "/favicon.ico";

    if (path.startsWith("//")) {
        // wikipedia special case, see tests
        if (urlForDomain.startsWith("https:"))
            return "https:" + path;

        return "http:" + path;
    } else if (path.startsWith("/"))
        return "http://" + extractHost(urlForDomain) + path;
    else if (path.startsWith("../")) {
        int slashIndex = urlForDomain.lastIndexOf("/");
        if (slashIndex > 0 && slashIndex + 1 < urlForDomain.length())
            urlForDomain = urlForDomain.substring(0, slashIndex + 1);

        return urlForDomain + path;
    }
    return path;
}

From source file:Main.java

public static String concatPath(String a, String b, String separator) {
    if (a.endsWith(separator) && b.startsWith(separator)) {
        return a + b.substring(1);
    } else if (a.endsWith(separator)) {
        return a + b;
    } else if (b.startsWith(separator)) {
        return a + b;
    }//from  w w  w  . java  2 s.co m
    return a + separator + b;
}

From source file:com.twitter.distributedlog.util.ConfUtils.java

/**
 * Load configurations with prefixed <i>section</i> from source configuration <i>srcConf</i> into
 * target configuration <i>targetConf</i>.
 *
 * @param targetConf/* ww w.j  a v  a  2 s  . c o  m*/
 *          Target Configuration
 * @param srcConf
 *          Source Configuration
 * @param section
 *          Section Key
 */
public static void loadConfiguration(Configuration targetConf, Configuration srcConf, String section) {
    Iterator confKeys = srcConf.getKeys();
    while (confKeys.hasNext()) {
        Object keyObject = confKeys.next();
        if (!(keyObject instanceof String)) {
            continue;
        }
        String key = (String) keyObject;
        if (key.startsWith(section)) {
            targetConf.setProperty(key.substring(section.length()), srcConf.getProperty(key));
        }
    }
}

From source file:Main.java

public static String getDataColumn(Context context, Uri uri, String selection, String[] selectionArgs) {

    Cursor cursor = null;//from   ww  w. j av  a  2 s.c o  m
    final String column = "_data";
    final String[] projection = { column };

    try {
        cursor = context.getContentResolver().query(uri, projection, selection, selectionArgs, null);
        if (cursor != null && cursor.moveToFirst()) {
            final int column_index = cursor.getColumnIndexOrThrow(column);
            String value = cursor.getString(column_index);
            if (value.startsWith("content://") || !value.startsWith("/") && !value.startsWith("file://")) {
                return null;
            }
            return value;
        }
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    return null;
}

From source file:Main.java

/**
 * Returns a path that can be safely concatenated with {@code authority}. If
 * the authority is null or empty, this can be any path. Otherwise the paths
 * run together like {@code http://android.comindex.html}.
 *//*w ww.  j  av  a2  s . co  m*/
public static String authoritySafePath(String authority, String path) {
    if (authority != null && !authority.isEmpty() && !path.isEmpty() && !path.startsWith("/")) {
        return "/" + path;
    }
    return path;
}

From source file:Main.java

public static boolean isSupportRange(HttpResponse response) {
    if (TextUtils.equals(getHeader(response, "Accept-Ranges"), "bytes")) {
        return true;
    }//from   www.  ja  va 2 s. co m
    String value = getHeader(response, "Content-Range");
    return value != null && value.startsWith("bytes");
}