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 boolean isIP(String input) {

    if (input.contains(".") && input.length() > 1) {
        return TextUtils.isDigitsOnly(input.replace(".", "").trim());
    } else {/*from   www  .j  a va 2 s .  c om*/
        return false;
    }
}

From source file:Main.java

public static String getHost(final String s) {
    if (s.contains("://")) {
        final String[] split = s.split("://");
        if (split.length > 1) {
            return split[1].split("\\?")[0];
        }/*from   w  w  w .j a  va2  s  .  c o  m*/
    }
    return null;
}

From source file:Main.java

public static String getFileExt(String filename) {
    if (!filename.contains(".")) {
        return "";
    } else {//from www.  j a  v a2  s  .c  o  m
        return filename.substring(filename.lastIndexOf(".") + 1, filename.length());
    }
}

From source file:Main.java

public static void setWebViewLayout(WebView webView, String content) {
    if (content.contains("<table")) {
        webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.NARROW_COLUMNS);
    } else {/*from ww  w.  j  a v  a  2 s  .  co  m*/
        webView.getSettings().setLayoutAlgorithm(LayoutAlgorithm.SINGLE_COLUMN);
    }
}

From source file:Main.java

private static String removeExtraSlashes(final String str) {
    if (str.contains("//")) {
        return removeExtraSlashes(str.replace("//", "/"));
    } else {/*from   w w w .j av a  2  s  .c o m*/
        return str;
    }
}

From source file:Main.java

/**
 * //from w w  w  .j  a  v a 2 s  .  c  o  m
 * @param uri
 * @return
 */
public static String parseNameFromURI(String uri) {

    if (!uri.contains("#")) {
        return uri;
    }

    return uri.substring(uri.lastIndexOf("#") + 1);
}

From source file:Main.java

public static String getPackageFromClassName(final String className) {
    if (className.contains(".")) {
        return className.substring(0, className.lastIndexOf('.'));
    }//  www .j  av a2  s  .co  m
    return className;
}

From source file:Main.java

public static String getRealAccNum(String selectorAccNum) {
    if (selectorAccNum.contains("/"))
        return selectorAccNum.split("/")[0];
    else/*from   w  w w.  j a va2s  .c om*/
        return selectorAccNum;
}

From source file:Main.java

public static String oidTail(String id) {
    if (id == null || !id.contains("."))
        return id;
    return id.substring(id.lastIndexOf(".") + 1);
}

From source file:Main.java

public static String removeComments(String xmlContent) {
    while (xmlContent.contains("<!--"))
        xmlContent = xmlContent.substring(0, xmlContent.indexOf("<!--"))
                + xmlContent.substring(xmlContent.indexOf("-->") + 3);

    return xmlContent;
}