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 boolean isValidComment(final String c) {
    assert (c != null) : c;
    if (c.contains("--")) {
        return false;
    }//from   www.  ja  v  a2 s. c  o m
    if (c.startsWith("-") || c.endsWith("-")) {
        return false;
    }
    return true;
}

From source file:se.alingsas.alfresco.repo.utils.CommonFileUtil.java

public static String parseValidFileName(String fileName) {
    while (fileName.endsWith(".")) {
        fileName = fileName.substring(0, fileName.length() - 1);
        fileName = fileName.trim();/* w  ww  .ja  va  2 s . co  m*/
    }
    fileName = fileName.replace("/", " ");
    fileName = fileName.replace("\\", " ");
    fileName = fileName.replace(":", " ");
    fileName = fileName.replace("\"", "\'");
    fileName = fileName.replace("?", "");
    fileName = fileName.replace("*", "");
    fileName = fileName.replace("|", " ");
    fileName = fileName.replace("<", " ");
    fileName = fileName.replace(">", " ");
    while (fileName.indexOf("  ") != -1) {
        fileName = fileName.replace("  ", " ");
    }
    fileName = fileName.trim();
    while (fileName.endsWith(".")) {
        fileName = fileName.substring(0, fileName.length() - 1);
        fileName = fileName.trim();
    }
    return fileName;
}

From source file:docbook.ArticleRoundTripTest.java

private static TestSuite listCases(File dir) {
    TestSuite cases = new TestSuite(dir.getName());
    String[] testFiles = dir.list(new FilenameFilter() {
        public boolean accept(File file, String filename) {
            return !filename.startsWith(".") && filename.endsWith(".docbook");
        }//w w w . ja  v  a 2  s .c  o  m
    });
    Arrays.sort(testFiles);
    for (String filename : testFiles) {
        File f = new File(dir, filename);
        if (f.isDirectory()) {
            cases.addTest(listCases(f));
        } else {
            String name = f.getAbsolutePath();
            if (f.getPath().startsWith(testDir.getPath() + '/')) {
                name = f.getPath().substring(testDir.getPath().length() + 1);
            }
            cases.addTest(new ArticleRoundTripTest(name));
        }
    }
    return cases;
}

From source file:com.thoughtworks.go.util.UrlUtil.java

public static String concatPath(String baseUrl, String path) {
    StringBuilder builder = new StringBuilder(baseUrl);
    if (!baseUrl.endsWith("/")) {
        builder.append('/');
    }/* ww w .  j  av  a2  s. c om*/
    builder.append(path);
    return builder.toString();
}

From source file:StringUtils.java

private static String fastRtrim(String toTrim, String pattern) {
    if (toTrim == null || pattern == null || pattern.equals("") || !toTrim.endsWith(pattern)) {
        return toTrim;
    }// ww  w  .  j ava2  s.c  om
    return fastRtrim(toTrim.substring(0, toTrim.length() - pattern.length()), pattern);
}

From source file:StringUtil.java

/**
 * Trims the quotes.// w ww.  j a  v  a2  s  .  co m
 * <p>
 * For example,
 * <ul>
 * <li>("a.b") => a.b
 * <li>("a.b) => "a.b
 * <li>(a.b") => a.b"
 * </ul>
 * 
 * @param value
 *            the string may have quotes
 * @return the string without quotes
 */

public static String trimQuotes(String value) {
    if (value == null)
        return value;

    value = value.trim();
    if (value.startsWith("\"") && value.endsWith("\""))
        return value.substring(1, value.length() - 1);

    return value;
}

From source file:Main.java

private static String getTempLocation() {

    String tmpdir = System.getProperty("java.io.tmpdir");
    StringBuilder sb = new StringBuilder();
    sb.append(tmpdir);/*from ww w.  j av  a2s.c  o m*/

    if (!tmpdir.endsWith(File.separator))
        sb.append(File.separator);

    sb.append("TempAzure");
    sb.append(File.separator);
    sb.append("MobileServiceTemplate");
    sb.append(File.separator);

    return sb.toString();
}

From source file:edu.cornell.mannlib.vitro.webapp.rdfservice.impl.virtuoso.RDFServiceVirtuoso.java

private static String noTrailingSlash(String uri) {
    return uri.endsWith("/") ? uri.substring(0, uri.length() - 1) : uri;
}

From source file:net.daboross.mccli.connect.LoggingClientListener.java

private static String parseJsonOpt(String str) {
    if (str.startsWith("{") && str.endsWith("}")) {
        return parseJsonMessage(new JSONObject(str));
    } else if (str.startsWith("\"") && str.endsWith("\"")) {
        str = str.substring(1, str.length() - 1).replaceAll("\\\\\"", "\"");
        return parseJsonOpt(str);
    } else {//from   w w  w .  j  a  v a  2  s.  co m
        return str;
    }
}

From source file:Main.java

private static String getTempLocation() {

    String tmpdir = System.getProperty("java.io.tmpdir");
    StringBuilder sb = new StringBuilder();
    sb.append(tmpdir);//from   w  w  w  .j  a va2s.c  o m

    if (!tmpdir.endsWith(File.separator))
        sb.append(File.separator);

    sb.append("TempAzure");
    sb.append(File.separator);

    return sb.toString();
}