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

public static String newFolder(String currFolder, String newFolder) {
    if (!currFolder.endsWith("/")) {
        currFolder += "/";
    }//  w w w .ja  va  2 s  .  c  om
    return currFolder + newFolder;
}

From source file:Main.java

public static String removeLast(String s, String pattern) {
    return s.endsWith(pattern) ? s.substring(0, s.length() - pattern.length()) : s; //cut off last pattern
}

From source file:Main.java

public static String fileNameAddEndJPG(String photoName) {
    if (null == photoName)
        return photoName;
    String name = photoName;
    if (!name.endsWith(".jpg"))
        name = name + ".jpg";
    return name;// w w  w  .  j  ava  2s.  com
}

From source file:Main.java

public static String RemoveLastPathSeperator(String uri) {
    if (uri.endsWith("/")) {
        return uri.substring(0, uri.length() - 1);
    } else {//from   www . j  ava  2  s .  co m
        return uri;
    }
}

From source file:Main.java

private static String removeTrailingNewLine(String s) {
    if (s.endsWith("\n")) {
        return s.substring(0, s.length() - 1);
    } else {/*ww  w  .j a  v  a  2 s  . c om*/
        return s;
    }
}

From source file:Main.java

public static String combinPath(String path, String fileName) {
    return path + (path.endsWith(File.separator) ? "" : File.separator) + fileName;
}

From source file:Main.java

/**
 * This function filters the input collection and returns a collection of elements ending with specified input.   
 * @param coll//from  w  ww .  j a v a  2  s.co m
 * @param str
 * @return Filtered Collection<String>
 */
public static Collection<String> endsWithString(Collection<String> coll, final String str) {
    Collection<String> list = new ArrayList<String>();
    for (String item : coll) {
        if (item.endsWith(str)) {
            list.add(item);
        }
    }
    return list;
}

From source file:Main.java

public static boolean isGifPicture(String url) {
    return !TextUtils.isEmpty(url) && url.endsWith(".gif");
}

From source file:Main.java

public static String getSSIDWithoutQuotes(String ssid) {
    if (ssid.startsWith("\"") && ssid.endsWith("\"")) {
        ssid = ssid.substring(1, ssid.length() - 1);
    }//from w w w  .ja  v a  2 s  .com

    return ssid;
}

From source file:Main.java

private final static boolean looksLikeImage(File src) {
    String n = src.getName().toLowerCase();
    return (n.endsWith(".jpg") || n.endsWith(".png") || n.endsWith(".gif"));
}