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

protected static boolean checkFileSuffix(String filePath) {
    for (int i = 0; i < _permittedSuffix.length; i++) {
        String lowerCase = filePath.toLowerCase();
        if (lowerCase.endsWith(_permittedSuffix[i])) {
            return true;
        }/*  w w w  .j  ava 2s.  co m*/
    }
    return false;
}

From source file:Main.java

public static String separator(String path) {
    path = path.replace('\\', '/');
    if (!path.endsWith("/"))
        path = path + "/";
    return path;/*  w w  w .ja  v a  2  s  .c  om*/
}

From source file:com.github.dokandev.dokanjava.samples.memoryfs.Utils.java

public static String trimTailBackSlash(String path) {
    if (path.endsWith("\\"))
        return path.substring(0, path.length() - 1);
    else/*www  .  j av  a  2  s  .  co m*/
        return path;
}

From source file:Main.java

/**
 * Formats the double as a string which is cleaned up a bit. This will return 0 for 0.0.
 * /*from   w w  w .ja  va  2s  . c  o  m*/
 * @param num Number to be formatted.
 * @return Number as a string.
 */
private static String formatAsString(double num) {
    String res = Double.toString(num);

    if (res.endsWith(".0")) {
        res = res.substring(0, res.length() - 2);
    }

    if (res.equals("-0")) {
        res = "0";
    }

    return res;
}

From source file:Main.java

/**
 * Make sure that the given path has the given suffix; if it doesn't
 * add the suffix./*from w  w  w .j  av a 2 s . co  m*/
 * 
 * @param suffix the suffix that the path must end with
 * @param path The path to add the suffix to if missing
 * 
 * @return The path with the suffix added if it was originally missing
 */
public static String ensurePathHasSuffix(String suffix, String path) {
    if (!path.endsWith(suffix)) {
        return path + suffix;
    } else {
        return path;
    }
}

From source file:Main.java

private static String concatServiceUrl(String baseUrl, String service) {
    return service.endsWith("/") ? baseUrl + service : baseUrl + "/" + service;
}

From source file:Main.java

public static String getPageName(String link, boolean cutQueries) {
    String s = link.trim();
    if (s.endsWith("/")) {
        s = s.substring(0, s.length() - 1);
    }// w ww.j a v  a2s  .c  o  m
    int i2 = -1;
    if (cutQueries)
        i2 = link.indexOf('?');
    if (i2 < 0)
        i2 = s.length();

    int i1 = s.lastIndexOf('/', i2) + 1;
    //      int i2 = -1;
    //      if (cutQueries)
    //         i2 = link.indexOf('?');
    //      if (i2 < 0)
    //         i2 = s.length();
    if (i1 < 0)
        i1 = 0;
    return s.substring(i1, i2);
}

From source file:Main.java

private static String getSimplifiedClassName(Class<?> klass) {
    String className = klass.getSimpleName();
    if (className.endsWith("Impl")) {
        className = className.substring(0, className.lastIndexOf("Impl"));
    }//from   w w w .ja v a  2s  . c o m
    return className;
}

From source file:Main.java

public static String trimWebdavSuffix(String url) {
    while (url.endsWith("/")) {
        url = url.substring(0, url.length() - 1);
    }//from ww w. ja v  a 2  s  .  c o m
    int pos = url.lastIndexOf(WEBDAV_PATH_4_0_AND_LATER);
    if (pos >= 0) {
        url = url.substring(0, pos);

    } else {
        pos = url.lastIndexOf(ODAV_PATH);
        if (pos >= 0) {
            url = url.substring(0, pos);
        }
    }
    return url;
}

From source file:Main.java

public static boolean isFLACFile(String in) {
    in = in.toLowerCase(Locale.US);
    return in.endsWith(".flac") || in.endsWith(".fla");
}