Example usage for java.lang String startsWith

List of usage examples for java.lang String startsWith

Introduction

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

Prototype

public boolean startsWith(String prefix) 

Source Link

Document

Tests if this string starts with the specified prefix.

Usage

From source file:Main.java

private static String getClassName(Type type) {
    if (type == null) {
        return "";
    }//from   w  w w  . ja  va  2  s  .co  m
    String clazzName = type.toString();
    if (clazzName.startsWith(TYPE_NAME_PREFIX)) {
        clazzName = clazzName.replace(TYPE_NAME_PREFIX, "");
    }
    return clazzName;
}

From source file:Main.java

public static void openBrowser(Context context, String url) {
    if (!TextUtils.isEmpty(url)) {
        if (!url.startsWith("http://") && !url.startsWith("https://")) {
            url = "http://" + url;
        }//from  w  ww  . ja  va  2s  .c om
        context.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url)));
    } else {
        Log.e("Helpers#openBrowser", "Something isn't right about the URL passed");
    }
}

From source file:Main.java

public static boolean isBinaryMimeType(String mimeType) {
    if (mimeType != null) {
        if (mimeType.startsWith("application/") && !mimeType.startsWith("application/xml")) {
            return true;
        } else if (mimeType.startsWith("image/") && !mimeType.startsWith("image/svg+xml")) {
            return true;
        } else if (mimeType.startsWith("audio/") || mimeType.startsWith("video/")) {
            return true;
        } else//  w  w w.j  a  v  a  2s . c  om
            return false;
    }
    return false;
}

From source file:Main.java

static public String addCDATAstring(String value) {
    String CDATAvalue = value;/*w ww .j av a 2 s . com*/
    if (!value.startsWith("<![CDATA[")) {
        CDATAvalue = "<![CDATA[" + value + "]]>";
    }
    return CDATAvalue.trim();
}

From source file:Main.java

public static Object str2Object(String info) {
    if (info.startsWith("[")) {
        return str2JsonList(info);
    } else {/*from  w  w w .  ja  va  2s  . c om*/
        return str2Json(info);
    }

}

From source file:Main.java

public static String getResourceAttributeValue(Node node, String resourceType, String attribute) {
    String currentNodeName = node.getNodeName();
    if (currentNodeName.startsWith(resourceType)) {
        return getAttributeValue(node, attribute);
    } else if (currentNodeName.startsWith(RESOURCE_ITEM)) {
        String typeValue = getAttributeValue(node, ATTRIBUTE_TYPE);
        if (resourceType.equals(typeValue)) {
            return getAttributeValue(node, attribute);
        }/*from w  w  w.j  a  v  a2 s  . c  om*/
    }
    return null;
}

From source file:Main.java

public static void deleteTempFiles() throws IOException {
    File file = createTempFile("test", "test");
    String folder = getDirectoryForFile(file.getAbsolutePath());
    String[] list = new File(folder).list(new FilenameFilter() {
        public boolean accept(File dir, String name) {
            return name.startsWith("ohfu-");
        }// w  w w  .  j  a  v  a2 s. com
    });
    if (list != null) {
        for (String n : list) {
            new File(path(folder, n)).delete();
        }
    }
}

From source file:Main.java

public static int getOptionalInt(Element element, String attribute, int defaultValue) {
    if (element.hasAttribute(attribute)) {
        String s = element.getAttribute(attribute);

        if (s.startsWith("+")) {
            s = s.substring(1);/*from   ww w.  j a  v  a2 s.  c o  m*/
        }

        return Integer.parseInt(s);
    }
    return defaultValue;
}

From source file:info.magnolia.objectfactory.ComponentConfigurationPath.java

public static boolean isComponentConfigurationPath(String s) {
    return s.startsWith("/") || s.indexOf(":/") >= 0;
}

From source file:Main.java

public static String removeQuotationsInCurrentSSIDForJellyBean(String ssid) {
    if (Build.VERSION.SDK_INT >= 17 && ssid != null && ssid.startsWith("\"") && ssid.endsWith("\""))
        ssid = ssid.substring(1, ssid.length() - 1);
    return ssid;/*from  ww  w. ja v  a2  s .  c  o m*/
}