Example usage for java.lang String contains

List of usage examples for java.lang String contains

Introduction

In this page you can find the example usage for java.lang String contains.

Prototype

public boolean contains(CharSequence s) 

Source Link

Document

Returns true if and only if this string contains the specified sequence of char values.

Usage

From source file:Main.java

public static List<String> getPackageAllClassName(Context context, String packageName) throws IOException {
    String sourcePath = context.getApplicationInfo().sourceDir;
    List<String> paths = new ArrayList<>();

    if (sourcePath != null) {
        DexFile dexfile = new DexFile(sourcePath);
        Enumeration<String> entries = dexfile.entries();

        while (entries.hasMoreElements()) {
            String element = entries.nextElement();
            if (element.contains(packageName)) {
                paths.add(element);/*ww  w  .  ja v a  2s.  co  m*/
            }
        }
    }

    return paths;
}

From source file:Main.java

public static String buildAccountName(Uri serverBaseUrl, String username) {
    if (serverBaseUrl.getScheme() == null) {
        serverBaseUrl = Uri.parse("https://" + serverBaseUrl.toString());
    }// ww  w  . j a  v a 2  s. co  m

    // Remove http:// or https://
    String url = serverBaseUrl.toString();
    if (url.contains("://")) {
        url = url.substring(serverBaseUrl.toString().indexOf("://") + 3);
    }
    String accountName = username + "@" + url;

    return accountName;
}

From source file:Main.java

private static boolean isRootOk(DataOutputStream output, DataInputStream input,
        final DataInputStream errInput) {
    if (output != null) {
        try {//  ww  w  . j av a  2s .c  o  m
            output.writeBytes("id\n");
            output.flush();
            String a = input.readLine();
            if (a.contains("root") || a.contains("uid=0")) {
                return true;
            }
            new Thread() {
                @Override
                public void run() {
                    try {
                        errInput.read();
                    } catch (IOException e) {
                        e.printStackTrace();
                    }
                };
            }.start();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    return false;
}

From source file:com.ansorgit.plugins.bash.lang.psi.util.BashIdentifierUtil.java

public static boolean isValidIdentifier(String name) {
    return StringUtils.stripToNull(name) != null && !name.contains(" ");
}

From source file:com.axibase.tsd.plain.AbstractInsertCommand.java

protected static String normalize(String value) {
    if (value.contains(" ")) {
        return "\"" + value + "\"";
    } else {/*from w w  w . ja  v a2  s.  c  o m*/
        return value;
    }
}

From source file:Main.java

public static String getFileNameWithouExtAndNumber(String filename) {
    filename = getFileNameWithoutExt(filename);
    if (filename.contains("-")) {
        return filename.substring(filename.indexOf("-") + 1, filename.length());
    }/*  w w  w .j av a  2 s.  c om*/
    return filename;
}

From source file:Main.java

/**
 * Indicates whether the specified window's title contains the given string.
 * @param window//  ww  w  . ja va2  s .  c om
 * the window to be checked
 * @param text
 * the text to be searched for
 * @return
 * true if the window's title contains text, otherwise false
 */
static boolean titleContains(Window window, String text) {
    String title = getWindowTitle(window);
    return (title != null && title.contains(text));
}

From source file:org.springframework.cloud.vault.VaultErrorMessage.java

/**
 * Obtain the error message from a JSON response.
 * /*w w w . j a  va2  s. co m*/
 * @param json
 * @return
 */
static String getError(String json) {

    if (json.contains("\"errors\":")) {

        try {
            Map<String, Object> map = OBJECT_MAPPER.readValue(json.getBytes(), Map.class);
            if (map.containsKey("errors")) {

                Collection<String> errors = (Collection<String>) map.get("errors");
                if (errors.size() == 1) {
                    return errors.iterator().next();
                }
                return errors.toString();
            }

        } catch (IOException o_O) {
            // ignore
        }
    }
    return json;
}

From source file:Main.java

public static boolean isNetworkAdbEnabled() {
    String result = propReader("service.adb.tcp.port");
    return !result.contains("-1") && result.contains("service.adb.tcp.port");
}

From source file:Main.java

public static boolean moreThanOne(String string) {
    if (string != null) {
        try {//from w ww .ja  va 2  s  .  c o m
            return string.contains("$");
            // return Integer.parseInt(string) > 0;
        } catch (Exception e) {
        }
    }
    return false;
}