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 isBlueToothName(String name) {

    if (!TextUtils.isEmpty(name) && name.startsWith("JY")) {
        return true;
    }//  www .j a  v a 2s . co m
    return false;
}

From source file:Main.java

/**
 * Checks wether the specified path expression is a self reference and
 * strips the self referencing expression portion.
 *
 * @param path the path expression.//w ww . j a  v a2  s  . c o m
 * @return the stripped path expression if the specified path path is
 * a self reference, otherwise the unmodified path expression.
 */
public static String stripSelfReference(String path) {
    if (path != null && path.startsWith("./")) {
        // strip self reference
        return path.substring(2);
    }

    // leave unmodified
    return path;
}

From source file:Main.java

public static String form(String name) {
    if (name.startsWith("\"") && name.endsWith("\"")) {
        name = name.substring(1, name.length() - 1);
    }/*www.ja  va2  s.co m*/

    if (name.startsWith("'") && name.endsWith("'")) {
        name = name.substring(1, name.length() - 1);
    }

    if (name.startsWith("`") && name.endsWith("`")) {
        name = name.substring(1, name.length() - 1);
    }

    name = name.toLowerCase();
    return name;
}

From source file:Main.java

/**
 * Method to correct a path. Splits last slash.
 * //from   w  ww. j  a  va  2  s  .  c  o  m
 * @param path
 * @return corrected path
 */
private static String checkPath(String path) {
    if (path.startsWith("/")) {
        path = path.substring(1, path.length());
    }
    return path;
}

From source file:Main.java

public static boolean isSpecialType(String url) {
    boolean isSpecial = url.startsWith(SCHEME_FILE) || url.startsWith(SCHEME_VIDEO)
            || url.startsWith(SCHEME_CONTENT) || url.startsWith(SCHEME_ANDROID_RESOURCE);
    return isSpecial;
}

From source file:Main.java

/**
 * DCL2 Adjust the name of the class to make the identification easier It is
 * done by converting all "/" to "."//from   w  ww .j  a v a2  s  .  co  m
 * 
 * Still "converts" the primitive types to your Wrapper.
 * 
 * @param className
 *            Name of the class
 * @return Adjusted class name
 */
public static String adjustClassName(String className) {
    if (className.startsWith("boolean") || className.startsWith("byte") || className.startsWith("short")
            || className.startsWith("long") || className.startsWith("double")
            || className.startsWith("float")) {
        return "java.lang." + className.toUpperCase().substring(0, 1) + className.substring(1);
    } else if (className.startsWith("int")) {
        return "java.lang.Integer";
    } else if (className.startsWith("int[]")) {
        return "java.lang.Integer[]";
    } else if (className.startsWith("char")) {
        return "java.lang.Character";
    } else if (className.startsWith("char[]")) {
        return "java.lang.Character[]";
    }
    return className.replaceAll("/", ".");
}

From source file:Main.java

public static String uuidToString(UUID uuid) {
    String uuidString = uuid.toString();

    if (uuidString.startsWith(BASE_UUID_START) && uuidString.endsWith(BASE_UUID_END)) {
        return uuidString.substring(4, 8);
    }/*  w  w  w. j  a v a 2s .  c o  m*/

    return uuidString;
}

From source file:Main.java

public static boolean isInternal(String path) {
    return TextUtils.isEmpty(path) || path.startsWith(Environment.getRootDirectory() + "/media")
            || path.startsWith(getDataSDCardRoot());
}

From source file:Main.java

public static boolean deleteFiles(final File directory, final String prefix) {
    for (File child : directory.listFiles(new FilenameFilter() {
        @Override/*from   ww w  . j a va  2  s.c  o  m*/
        public boolean accept(File dir, String name) {
            return name.startsWith(prefix);
        }
    })) {
        deleteRecursive(child);
    }
    return true;
}

From source file:Main.java

public static String getName(Class clazz) {
    String name = clazz.getName();
    if (name.startsWith("scouter.agent.") == false)
        return name;
    return "Scouter-" + name.substring(name.lastIndexOf('.') + 1);
}