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:com.abiquo.nodecollector.domain.collectors.AbstractCollector.java

/**
 * Removes the trailing slash from the given String.
 * //ww  w .j  a v  a  2 s .c  om
 * @param text The String to modify.
 * @return The String without the trailing slash.
 */
protected static String removeTrailingSlash(final String text) {
    if (text.endsWith("/")) {
        return text.substring(0, text.length() - 1);
    } else {
        return text;
    }
}

From source file:com.milaboratory.core.io.CompressionType.java

public static CompressionType detectCompressionType(String fileName) {
    fileName = fileName.trim().toLowerCase();

    if (fileName.endsWith(".gz"))
        return GZIP;
    else if (fileName.endsWith(".bz2"))
        return BZIP2;
    return None;/*from w ww .  j a va2  s . com*/
}

From source file:com.servoy.j2db.server.ngclient.startup.resourceprovider.ComponentResourcesExporter.java

/**
 * Used in war export to create a services.properties file, which is needed to load services specs in the war.
 * @return the locations of services folders relative to the war dir.
 *///from w w w.  ja v a2  s. c  o m
public static String getServicesDirectoryNames() {
    StringBuilder locations = new StringBuilder();
    Enumeration<String> paths = Activator.getContext().getBundle().getEntryPaths("/war/");
    while (paths.hasMoreElements()) {
        String name = paths.nextElement().replace("war/", "");
        if (name.endsWith("services/"))
            locations.append("/" + name + ";");
    }
    if (locations.length() > 0)
        locations.deleteCharAt(locations.length() - 1);
    return locations.toString();
}

From source file:de.uni.bremen.monty.moco.ast.expression.literal.StringLiteral.java

/** Removes leading and trailing quotes of string literals
 *
 * @param value/*www  .  j a v a2s.c  o  m*/
 *            the string to prepare
 * @return value without leading and trailing quotes */
protected static String prepareStrLiteral(String value) {
    if ((value.startsWith("\"")) && (value.endsWith("\""))) {
        value = value.substring(1, value.length() - 1);
    }
    return value;
}

From source file:Main.java

public static String getMimeType(String filename) {
    String mimeType = null;//w  w  w. java 2  s  .  com

    if (filename == null) {
        return mimeType;
    }
    if (filename.endsWith(".3gp")) {
        mimeType = "video/3gpp";
    } else if (filename.endsWith(".mid")) {
        mimeType = "audio/mid";
    } else if (filename.endsWith(".mp3")) {
        mimeType = "audio/mpeg";
    } else if (filename.endsWith(".xml")) {
        mimeType = "text/xml";
    } else {
        mimeType = "";
    }
    return mimeType;
}

From source file:Main.java

public static boolean checkComment(String contents) {
    if (contents == null)
        return true; // ?
    return contents.indexOf("--") < 0 && !contents.startsWith("-") && !contents.endsWith("-");
}

From source file:Main.java

public static boolean isImage(String filePath) {
    if (TextUtils.isEmpty(filePath)) {
        return false;
    }//  www.  j a  va  2  s . c  o m

    filePath = filePath.toLowerCase();
    if ((!filePath.endsWith(".jpg") && !filePath.endsWith(".jpeg") && !filePath.endsWith(".png")
            && !filePath.endsWith(".bmp") && !filePath.endsWith(".gif"))) {
        return false;
    }
    return true;
}

From source file:com.servoy.j2db.server.ngclient.startup.resourceprovider.ComponentResourcesExporter.java

/**
 * Used in war export to create a components.properties file which is needed to load the components specs in war.
 * @return the locations of components folders relative to the war dir.
 *//*  ww  w .ja v  a  2 s .  c  om*/
public static String getComponentDirectoryNames() {
    StringBuilder locations = new StringBuilder();
    Enumeration<String> paths = Activator.getContext().getBundle().getEntryPaths("/war/");
    while (paths.hasMoreElements()) {
        String name = paths.nextElement().replace("war/", "");
        if (name.endsWith("/") && !name.equals("js/") && !name.equals("css/") && !name.equals("templates/")
                && !name.endsWith("services/")) {
            locations.append("/" + name + ";");
        }
    }
    locations.deleteCharAt(locations.length() - 1);
    return locations.toString();
}

From source file:kr.ac.kaist.wala.hybridroid.shell.Shell.java

/**
 * Read the target file from the disk.//from  w w w .  j a  v  a2  s  .  c  o  m
 * 
 * @param target
 *            the path that indicates the target file.
 * @return target file for analysis.
 */
private static File getTargetFile(String target) throws WalaException {
    if (!target.endsWith(".apk"))
        throw new WalaException("target file must be 'apk' file. TARGET: " + target);

    return new File(target);
}

From source file:org.sventon.model.SVNURL.java

private static String trim(String url) {
    if (url.endsWith("/")) {
        return url.substring(0, url.length() - 1);
    }/*  w  ww  .  j ava 2s  .  c om*/
    return url;
}