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

private static int parseSingleChanel(String chanel) {
    if (chanel.contains("%")) {
        float percent = Float.parseFloat(chanel.replaceAll("[^0-9\\.]", ""));
        return (int) (255 * (percent / 100));
    }/*from   w  ww . j  a  v  a 2 s  . c  om*/
    return Integer.parseInt(chanel.replaceAll("[^0-9]", ""));
}

From source file:Main.java

public static String addQuoteMark(String s) {
    if (!TextUtils.isEmpty(s) && s.charAt(0) != '"' && !s.contains("*"))
        s = (new StringBuilder()).append("\"").append(s).append("\"").toString();
    return s;//w ww  . j  a v  a 2  s  .c om
}

From source file:Main.java

public static boolean contains(String srcText, CharSequence targetText) {
    return srcText != null && srcText.contains(targetText);
}

From source file:Main.java

public static String nameFromEmail(String email) {

    if (isEmptyTrimmed(email) || !email.contains("@")) {
        return email;
    }/*  w w w.j  av  a  2 s . c  om*/

    int atIndex = email.indexOf("@");

    return email.substring(0, atIndex);
}

From source file:Main.java

public static boolean contains(String str, boolean in, String... strs) {
    for (String s : strs) {
        if (in) {
            if (s.contains(str))
                return true;
        } else {// ww  w  .  j a v a2 s .  c  o  m
            if (str.contains(s))
                return true;
        }
    }
    return false;
}

From source file:Main.java

private static boolean isValidEmail(String email) {
    if (email.contains(".") && email.contains("@")) {
        return true;
    }//  ww  w  .j  a va 2s.  c  om

    return false;
}

From source file:Main.java

public static boolean isSmbVideo(Uri uri) {
    if (uri == null) {
        return false;
    }//from   ww  w.j ava 2  s .  c  o  m

    String path = uri.toString();
    if (path != null && path.contains("app_smb")) {
        return true;
    } else {
        return false;
    }
}

From source file:Main.java

private static void extractValue(Map<String, String> result, String eleName, String content) {
    if (eleName != null && eleName.contains(":")) {
        String cs[] = eleName.split(":");
        result.put(cs[1], content);//  w  w  w.j  a  va2s  .co  m
    } else {
        result.put(eleName, content);
    }
}

From source file:Main.java

/**
 * Parcourt les fichiers dans /assets/ et renvoie la liste des fichiers dont leurs noms est
 * de la forme suivante : XXX____gallery_borneathXXX X pouvant etre une chaine de caracteres
 * vide/*from   w  w  w.  ja  v a2  s .  co  m*/
 * @param context utilisee
 * @return liste de chaine de caracteres (nom d'image)
 * @throws IOException
 */
public static List<String> getImagesPathFromAssets(Context context) throws IOException {
    AssetManager assetManager = context.getAssets();
    String[] files = assetManager.list(ASSETS_IMAGES_FOLDER);
    List<String> sortedFileNames = new ArrayList<>();
    for (String fileName : files) {
        if (fileName.contains(ASSETS_PATH_NAME_PATTERN)) {
            sortedFileNames.add(ASSETS_IMAGES_FOLDER + FILE_SEPARATOR + fileName);
        }
    }
    return sortedFileNames;
}

From source file:Main.java

public static boolean listContains(List<String> list, String text) {
    for (String elem : list) {
        if (text.contains(elem)) {
            return true;
        }/*from  ww  w  .ja  va 2s  . c o m*/
    }
    return false;
}