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 String getParentPath(String path) {
    if (!path.contains(FS)) {
        return FS;
    }//  w w  w .  ja  va2s . com
    if (path.lastIndexOf(FS) < 2) {
        return FS;
    }
    String pass1 = path.substring(0, path.lastIndexOf(FS));
    pass1 = pass1.substring(0, pass1.lastIndexOf(FS));
    Log.i(ID, "getParentPath: " + path + " -> " + pass1);
    return pass1;
}

From source file:Main.java

private static boolean isWhitespace(int code, String whitespace) {
    return whitespace.contains(String.valueOf((char) code));
}

From source file:Main.java

/**
 * XML attribute value Encode/*w w  w.j  a  va2s .  co  m*/
 * @param s xml attribute values
 * @return convert "&"->"&amp;", "<"->"&lt;", ">"->"&gt;" 
 */
public static String encodeXMLReservedWords(String s) {
    if (s.contains("&")) {
        s = s.replaceAll("&", "&amp;");
    }

    if (s.contains("<")) {
        s = s.replaceAll("<", "&lt;");
    }

    if (s.contains(">")) {
        s = s.replaceAll(">", "&gt;");
    }
    return s;
}

From source file:Main.java

public static String getMimeType(String url) {
    if (url != null && url.contains(".m3u8")) {
        return MIME_VIDEO_HLS;
    } else {/*  w w  w .j av  a2s.c  om*/
        return MIME_VIDEO_MP4;
    }
}

From source file:Main.java

public static String removeDuplicate(String newInfo, String oldInfo) {
    if (!newInfo.contains(oldInfo)) {
        newInfo += oldInfo + ",";
    }/* w  w w . j  av a2  s.c om*/
    return newInfo;
}

From source file:Main.java

public static String getHostFromUrl(String url) {
    if (url.contains(COLON)) {
        return url.substring(0, url.indexOf(COLON));
    } else {/*from  www  .  j ava 2  s . c o m*/
        return url;
    }
}

From source file:Main.java

private static String removeLast(String s, String g) {
    if (s.contains(g)) {
        int index = s.lastIndexOf(g);
        int indexEnd = index + g.length();
        if (index == 0)
            return s.substring(1);
        else if (index == s.length() - 1)
            return s.substring(0, index);
        else/* ww w  .  j a  v  a2s.c  o  m*/
            return s.substring(0, index) + s.substring(indexEnd);
    }
    return s;
}

From source file:Main.java

private static String getHash(String s) {
    if (s.contains("/comment/")) {
        s = s.substring(0, s.indexOf("/comment"));
    }//  w ww .j  a  v a 2s  . co m
    String next = s.substring(s.lastIndexOf("/"), s.length());
    if (next.contains(".")) {
        next = next.substring(0, next.indexOf("."));
    }
    if (next.startsWith("/")) {
        next = next.substring(1, next.length());
    }
    if (next.length() < 5) {
        return getHash(s.replace(next, ""));
    } else {
        return next;
    }

}

From source file:Main.java

public static int wifiType(String capabilities) {
    if (capabilities.contains("WPA")) {
        return WIFI_WPA;
    } else if (capabilities.contains("WEP")) {
        return WIFI_WEP;
    } else if (capabilities.contains("WPS")) {
        return WIFI_WPS;
    } else {/*from w w  w . j a  va2  s.c om*/
        return WIFI_PASS;
    }
}

From source file:Main.java

private static String removeLast(String s, String g) {
    if (s.contains(g)) {
        int index = s.lastIndexOf(g);
        int indexEnd = index + g.length();
        if (index == 0) {
            return s.substring(1);
        } else if (index == (s.length() - 1)) {
            return s.substring(0, index);
        } else {//from   ww  w .ja v a 2  s  .  co  m
            return s.substring(0, index) + s.substring(indexEnd);
        }
    }
    return s;
}