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:api.behindTheName.NameReader.java

static HashMap<String, String> load() {
    HashMap<String, String> data = new HashMap<>();

    File file = new File("options.txt");

    try {/* w w  w  .jav  a2s.com*/
        List<String> lines = FileUtils.readLines(file);
        for (String s : lines) {
            if (s.contains("#"))
                continue;
            String htk = s.split("\\s")[0];
            String cntry = s.substring(htk.length() + 1);
            data.put(cntry, htk);
        }
    } catch (IOException ex) {
        Logger.getLogger(NameReader.class.getName()).log(Level.SEVERE, null, ex);
    }

    return data;

}

From source file:Main.java

public static boolean deviceInAecBlacklisted() {
    List<String> blackListedModels = Arrays.asList(BLACKLISTED_AEC_MODELS);
    for (String blackModel : blackListedModels) {
        String model = Build.MODEL;
        if (!TextUtils.isEmpty(model) && model.contains(blackModel)) {
            return true;
        }//from  ww  w.j  a v a 2  s .  c o  m
    }
    return false;
}

From source file:com.teradata.tempto.internal.convention.TableName.java

public static TableName parse(String value) {
    if (value.contains(".")) {
        List<String> parts = Splitter.on('.').splitToList(value);
        checkState(parts.size() == 2,//from  ww  w  . j a va  2 s  .c o m
                "Invalid table name syntax. Expected at most one occurrence of '.' in '%s'.", value);
        return new TableName(parts.get(1), Optional.of(parts.get(0)));
    } else {
        return new TableName(value, Optional.empty());
    }
}

From source file:Main.java

public static String getDirectory(String path) {
    String osName = System.getProperty("os.name");
    // test(osName);
    if (osName.contains("Win")) {
        path = path.substring(0, path.lastIndexOf('\\') + 1);
    } else {/*from w  w w.ja v  a2  s.  c o m*/
        path = path.substring(0, path.lastIndexOf('/') + 1);
    }
    return path;
}

From source file:Main.java

public static void deleteFromInternalStorage(Context context, final String contains) throws IOException {
    File file = context.getFilesDir();
    FilenameFilter filter = new FilenameFilter() {
        @Override//from  w  w  w  .j  a v  a2s.c om
        public boolean accept(File dir, String filename) {
            return filename.contains(contains);
        }
    };
    File[] files = file.listFiles(filter);
    if (files != null) {
        for (File f : files) {
            //noinspection ResultOfMethodCallIgnored
            if (!f.delete()) {
                throw new IOException("Error while deleting files");
            }
        }
    }
}

From source file:com.thoughtworks.twist.mingle.core.MingleUtils.java

public static String getQueryUrlAfterEncodingURL(String fullUrl) throws UnsupportedEncodingException {
    String queryUrl = fullUrl.substring(fullUrl.indexOf('?') + 1);
    String[] split = queryUrl.split("&");
    ArrayList<NameValuePair> pairs = new ArrayList<NameValuePair>();
    for (String nameValuePair : split) {
        if (nameValuePair.contains("=")) {
            int indexOfEquals = nameValuePair.indexOf('=');
            String name = nameValuePair.substring(0, indexOfEquals);
            String value = nameValuePair.substring(indexOfEquals + 1);
            name = URLDecoder.decode(name, "utf-8");
            value = URLDecoder.decode(value, "utf-8");
            pairs.add(new NameValuePair(name, value));
        }/*from w w w  .j a v a 2 s.  c om*/
    }
    String formUrlEncode = EncodingUtil.formUrlEncode(pairs.toArray(new NameValuePair[0]), "utf-8");
    return formUrlEncode;
}

From source file:Main.java

public static String makeItUrl(String str) {//TODO move
    if (!str.startsWith(HTTP)) {
        if (str.contains(HTTP)) {
            str = str.substring(str.indexOf(HTTP)).replace("\"", "").replace("\\", "").replace("]", "");//1202 0304 
        } else {/*  ww  w  .j  a  v a2 s .  co  m*/
            Log.e("jackUtil", "url illegal:" + str);
            str = "";
        }
    }
    return str;
}

From source file:Main.java

/**
 * Takes a character sequence with a single character and checks if the character occurs
 * in a list of word separators or is empty.
 * @param singleChar A CharSequence with null, zero or one character
 * @param wordSeparators A String containing the word separators
 * @return true if the character is at a word boundary, false otherwise
 *//*ww w.  ja  v a 2s  .  com*/
private static boolean isWordBoundary(CharSequence singleChar, String wordSeparators) {
    return TextUtils.isEmpty(singleChar) || wordSeparators.contains(singleChar);
}

From source file:com.sylvanaar.idea.Lua.lang.psi.util.LuaIdentifierUtil.java

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

}

From source file:Main.java

public static boolean isDouble(String value) {
    try {//from   ww w .j  a  va2s  .c  o  m
        Double.parseDouble(value);
        if (value.contains("."))
            return true;
        return false;
    } catch (NumberFormatException e) {
        return false;
    }
}