Example usage for java.lang String endsWith

List of usage examples for java.lang String endsWith

Introduction

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

Prototype

public boolean endsWith(String suffix) 

Source Link

Document

Tests if this string ends with the specified suffix.

Usage

From source file:Main.java

/**
 * Combined the namespace and the local name back together.
 * @param ns the namespace uri//from w w  w.  j  a va 2s  . c  om
 * @param lname the local name
 * @param joiner the join string, e.g. <code>#</code>
 * @return the joined uri
 */
public static String unsplit(String ns, String lname, String joiner) {
    if (!ns.endsWith(joiner)) {
        ns += joiner;
    }
    try {
        return ns + URLEncoder.encode(lname, charset);
    } catch (UnsupportedEncodingException e) {
        throw new RuntimeException("You don't support " + charset + "?");
    }
}

From source file:Main.java

static public String[] splitUri(String uri) {
    if (uri.startsWith("/"))
        uri = uri.substring(1);/*ww w  .  j  ava  2  s  .c  o  m*/
    if (uri.endsWith("/"))
        uri = uri.substring(0, uri.length() - 2);
    return uri.split("/");
}

From source file:Main.java

public static String normalizeUrlSuffix(String url) {
    String normalizedUrl = url;
    if (normalizedUrl.endsWith("/")) {
        normalizedUrl = normalizedUrl.substring(0, normalizedUrl.length() - 1);
    }/*from  ww w  .  ja  v  a2s.c om*/
    return trimUrlWebdav(normalizedUrl);
}

From source file:Main.java

public static List<String> getSharedPreferenceTags(Context context) {
    ArrayList<String> tags = new ArrayList<String>();

    String rootPath = context.getApplicationInfo().dataDir + "/shared_prefs";
    File root = new File(rootPath);
    if (root.exists()) {
        for (File file : root.listFiles()) {
            String fileName = file.getName();
            if (fileName.endsWith(PREFS_SUFFIX)) {
                tags.add(fileName.substring(0, fileName.length() - PREFS_SUFFIX.length()));
            }//  w  ww  . ja v  a  2  s .co  m
        }
    }

    Collections.sort(tags);

    return tags;
}

From source file:Main.java

public static boolean isTransferCategory(String category) {
    return !TextUtils.isEmpty(category) && category.startsWith("[") && category.endsWith("]");
}

From source file:Main.java

public static boolean isFreelineProcess(Context context) {
    String processName = getCurProcessName(context);
    return processName.endsWith(":freeline");
}

From source file:at.bitfire.davdroid.URIUtils.java

public static String ensureTrailingSlash(String href) {
    if (!href.endsWith("/")) {
        Log.d(TAG, "Implicitly appending trailing slash to collection " + href);
        return href + "/";
    } else//from   www  .  ja  va2  s  . c om
        return href;
}

From source file:Main.java

public static boolean isTextXML(String text) {
    text = text.trim();//w  ww. j a  va  2  s .  c om
    if (!(text.startsWith("<") && text.endsWith(">")))
        return false; //If text doesn't begin with "<" it's not XML

    int firstClose = text.indexOf(">");
    int lastOpen = text.lastIndexOf("<");

    if (lastOpen == 0 && text.lastIndexOf("/") == firstClose - 1)
        return true; //Example "<DIMES />
    if (text.substring(1, firstClose + 1).equals(text.substring(lastOpen + 2)))
        return true; //<XML> blah </XML>

    return false;
}

From source file:Main.java

public static String interceptStrToCity4Tai(String area, String taiStr) {
    if (area != null && !area.equals("")) {
        if (area.endsWith(taiStr)) {
            area = area.substring(0, area.length() - 1);
        }//from  w  ww  .j av  a2 s  . com
    }
    return area;
}

From source file:Main.java

/**
 * Return true if the host is a known URL shortener
 *//*from w  w w  .jav a 2s . com*/
public static boolean isRedirect(String host) {
    for (String REDIRECT_HOST : REDIRECT_HOSTS) {
        if (host.endsWith(REDIRECT_HOST))
            return true;
    }
    return false;
}