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:org.ow2.chameleon.everest.internals.JSONUtils.java

/**
 * Tests if the String possibly represents a valid JSON String.<br>
 * Valid JSON strings are:/*from   ww  w .  ja va2s.co  m*/
 * <ul>
 * <li>"null"</li>
 * <li>starts with "[" and ends with "]"</li>
 * <li>starts with "{" and ends with "}"</li>
 * </ul>
 */
public static boolean mayBeJSON(String string) {
    return string != null && ("null".equals(string) || (string.startsWith("[") && string.endsWith("]"))
            || (string.startsWith("{") && string.endsWith("}")));
}

From source file:ch.lipsch.subsonic4j.internal.SubsonicUtil.java

private static String addSlashIfNecessary(String url) {
    if (!url.endsWith("/")) {
        return url + "/";
    }/*from   w w w  .j  a  v  a  2 s  .  c  om*/
    return url;
}

From source file:com.kstenschke.shifter.models.shiftertypes.JsVariablesDeclarations.java

/**
 * Check whether given string represents a declaration of JS variables:
 * -selection has multiple lines//from  www.  j  a va 2 s  .c o m
 * -each trimmed line starts w/ "var" (at least 2 occurrences)
 * -each trimmed line ends w/ ";"
 * -there can be empty lines
 * -there can commented lines, beginning w/ "//"
 *
 * @param  str     String to be checked
 * @return boolean
 */
public static Boolean isJsVariables(String str) {
    str = str.trim();
    if (!str.startsWith("var") || !str.endsWith(";") || !str.contains("\n")
            || StringUtils.countMatches(str, "var") < 2 || StringUtils.countMatches(str, ";") < 2) {
        return false;
    }

    return true;
}

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

/**
 * @param path/*from   w w w. j  a  va2 s.co m*/
 * @param tmpWarDir
 * @throws IOException 
 */
private static void copy(Enumeration<String> paths, File destDir) throws IOException {
    if (paths != null) {
        while (paths.hasMoreElements()) {
            String path = paths.nextElement();
            if (path.endsWith("/")) {
                File targetDir = new File(destDir,
                        FilenameUtils.getName(path.substring(0, path.lastIndexOf("/"))));
                copy(Activator.getContext().getBundle().getEntryPaths(path), targetDir);
            } else {
                URL entry = Activator.getContext().getBundle().getEntry(path);
                FileUtils.copyInputStreamToFile(entry.openStream(),
                        new File(destDir, FilenameUtils.getName(path)));
            }
        }
    }
}

From source file:io.trivium.anystore.StoreUtils.java

public static void cleanStore() {
    Logger logger = Logger.getLogger(StoreUtils.class.getName());
    logger.info("cleaning persistence store");
    String path = Central.getProperty("basePath");
    if (!path.endsWith(File.separator))
        path += File.separator;/*  w  w w  .  j  a  va 2 s .co m*/
    path += "store" + File.separator;
    try {
        File f = new File(path + meta);
        if (f.exists())
            FileUtils.deleteQuietly(f);
    } catch (Exception e1) {
        logger.log(Level.SEVERE, "cleaning meta store failed", e1);
    }
    try {
        File f = new File(path + data);
        if (f.exists())
            FileUtils.deleteQuietly(f);
    } catch (Exception e1) {
        logger.log(Level.SEVERE, "cleaning data store failed", e1);
    }
    try {
        File f = new File(path + local);
        if (f.exists())
            FileUtils.deleteQuietly(f);
    } catch (Exception e1) {
        logger.log(Level.SEVERE, "cleaning local store failed", e1);
    }
}

From source file:me.dags.creativeblock.blockpack.FolderBlockPack.java

private static IOFileFilter definitionsFilter() {
    return new IOFileFilter() {
        @Override//w  w  w. j  av a  2s . c  om
        public boolean accept(File file) {
            return file.isFile();
        }

        @Override
        public boolean accept(File dir, String name) {
            return name.endsWith(".json");
        }
    };
}

From source file:me.dags.creativeblock.blockpack.FolderBlockPack.java

private static IOFileFilter textureFilter() {
    return new IOFileFilter() {
        @Override//from  ww w .  jav a 2s .  com
        public boolean accept(File file) {
            return file.isFile();
        }

        @Override
        public boolean accept(File dir, String name) {
            return name.endsWith(".png");
        }
    };
}

From source file:Main.java

private static float getFloatFromString(String s) {
    if (s != null && !s.trim().equals("")) {
        s = s.replaceAll(",", "");

        try {/*from   w w  w .j  av  a  2  s. c  o m*/
            if (s.endsWith("%")) {
                return Float.valueOf(s.substring(0, s.length() - 1));
            } else {
                return Float.valueOf(s);
            }
        } catch (NumberFormatException e) {
        }
    }

    return 0;
}

From source file:fedroot.dacs.http.DacsCookie.java

private static boolean isDacsSelectCookieName(String cookieName) {
    return (cookieName.startsWith("DACS:") && cookieName.endsWith(":SELECT"));
}

From source file:aurelienribon.utils.io.FilenameHelper.java

/**
 * Removes every '"' character before and after the path, if any.
 *///from w  w  w  .ja va 2 s  .c  om
public static String trim(String path) {
    while (path.startsWith("\"") && path.endsWith("\""))
        path = path.substring(1, path.length() - 1);
    return path;
}