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:io.trivium.anystore.StoreUtils.java

public static void cleanQueue() {
    Logger logger = Logger.getLogger(StoreUtils.class.getName());
    logger.info("cleaning queue storage");
    String path = Central.getProperty("basePath");
    if (!path.endsWith(File.separator))
        path += File.separator;//w w  w  . j a  v a 2  s.c  om
    try {
        File f = new File(path + "queues" + File.separator);
        if (f.exists())
            FileUtils.deleteQuietly(f);
    } catch (Exception e1) {
        logger.log(Level.SEVERE, "cleaning queue storage failed", e1);
    }
}

From source file:Main.java

/**
 * Create a list of all the .class files within a directory.
 * @param path Location from where extract the files.
 * @param fileNames List where store all the files names.
 * @param parent Parent path./*  w  ww  . j  av a  2s . c  o m*/
 */
private static void populateFiles(File path, List<String> fileNames, String parent) {
    if (path.isDirectory()) {
        for (File newPath : path.listFiles()) {
            if ("".equals(parent)) {
                populateFiles(newPath, fileNames, path.getName());
            } else {
                populateFiles(newPath, fileNames, parent + "." + path.getName());
            }
        }
    } else {
        String pathName = path.getName();
        String classSuffix = ".class";
        pathName = pathName.endsWith(classSuffix)
                ? pathName.substring(0, pathName.length() - classSuffix.length())
                : pathName;
        if ("".equals(parent)) {
            fileNames.add(pathName);
        } else {
            fileNames.add(parent + "." + pathName);
        }
    }
}

From source file:com.github.mjeanroy.junit.servers.samples.jetty.webxml.IndexWithRunnerTest.java

@TestServerConfiguration
private static EmbeddedJettyConfiguration configuration() throws Exception {
    String current = new File(".").getCanonicalPath();
    if (!current.endsWith("/")) {
        current += "/";
    }//from ww  w.j  a  v  a  2s  . c o m

    String subProjectPath = "samples/spring-webxml-jetty/";
    String path = current.endsWith(subProjectPath) ? current : current + subProjectPath;

    return EmbeddedJettyConfiguration.builder().withWebapp(path + "src/main/webapp")
            .withClasspath(path + "target/classes").build();
}

From source file:com.github.mjeanroy.junit.servers.samples.tomcat.webxml.IndexWithRunnerTest.java

@TestServerConfiguration
private static EmbeddedTomcatConfiguration configuration() throws Exception {
    String current = new File(".").getCanonicalPath();
    if (!current.endsWith("/")) {
        current += "/";
    }/*  w ww.j a  v a2s.  c o m*/

    String subProjectPath = "samples/spring-webxml-tomcat/";
    String path = current.endsWith(subProjectPath) ? current : current + subProjectPath;

    return EmbeddedTomcatConfiguration.builder().withWebapp(path + "src/main/webapp")
            .withClasspath(path + "target/classes").build();
}

From source file:de.tudarmstadt.ukp.dkpro.core.api.resources.CompressionUtils.java

/**
 * Get an uncompressed input stream for a given input stream created for a particular location.
 * //from w  w  w .jav a 2  s.  c  o m
 * @param aLocation a resource location (e.g. a path, url, etc.)
 * @param aStream a raw stream of potentially compressed data.
 * @return stream wrapped with a decompressing stream.
 */
public static InputStream getInputStream(String aLocation, InputStream aStream) throws IOException {
    String lcLocation = aLocation.toLowerCase();
    if (lcLocation.endsWith(GZIP.getExtension())) {
        return new GZIPInputStream(aStream);
    } else if (lcLocation.endsWith(BZIP2.getExtension()) || lcLocation.endsWith(".bzip2")) {
        return new BZip2CompressorInputStream(aStream);
    } else if (lcLocation.endsWith(XZ.getExtension())) {
        return new XZCompressorInputStream(aStream);
    } else {
        return aStream;
    }
}

From source file:edu.cmu.cs.lti.ark.util.SerializedObjects.java

public static OutputStream getOutputStream(String outFile) throws IOException {
    if (outFile.endsWith(".gz")) {
        return new GZIPOutputStream(new FileOutputStream(outFile));
    } else {/*from w ww  . ja  v a 2s . co m*/
        return new FileOutputStream(outFile);
    }
}

From source file:me.ardacraft.blocksapi.helper.LangHelper.java

private static String getNeatName(String s) {
    String name = s.substring(5).replace(".name", "").replace("_", " ");
    if (name.endsWith(" Block")) {
        return name.replace(" Block", "");
    }/*from  w w w  . j  a v  a2 s.  c om*/
    return WordUtils.capitalizeFully(name);
}

From source file:Main.java

private static String readXsdVersionFromFile(Document doc) {
    final String JBOSS_ESB = "jbossesb";
    NodeList nodes = doc.getChildNodes();
    if (nodes != null) {
        for (int i = 0; i < nodes.getLength(); i++) {
            Node node = nodes.item(i);
            if (JBOSS_ESB.equals(node.getNodeName())) {
                NamedNodeMap attributes = node.getAttributes();
                for (int j = 0; j < attributes.getLength(); j++) {
                    Node attribute = attributes.item(j);
                    if ("xmlns".equals(attribute.getNodeName())) {
                        String value = attribute.getNodeValue();
                        if (value.contains(JBOSS_ESB) && value.endsWith(".xsd"))
                            return value.substring(value.lastIndexOf('/') + 1, value.length());
                        else
                            throw new IllegalStateException(
                                    "The ESB descriptor points to an invalid XSD" + value);
                    }//from   w ww. j a v a2s.c o  m
                }
            }
        }
        throw new IllegalArgumentException("No root node " + JBOSS_ESB + " found.");
    } else
        throw new IllegalArgumentException("Descriptor has no root element !");
}

From source file:Main.java

/**
 * Creates an output stream to write to a regular or compressed file.
 * //  ww  w .j  a v a2 s .  co m
 * @param fileName    a file name with an extension .gz or without it;
 *                    if the user specifies an extension .gz, we assume
 *                    that the output file should be compressed.
 * @return an output stream to write to a file.
 * @throws IOException
 */
public static OutputStream createOutputStream(String fileName) throws IOException {
    OutputStream foutp = new FileOutputStream(fileName);
    if (fileName.endsWith(".gz"))
        return new GZIPOutputStream(foutp);
    if (fileName.endsWith(".bz2")) {
        throw new IOException("bz2 is not supported for writing");
    }
    return foutp;
}

From source file:asia.gkc.vneedu.utils.FileUtil.java

/**
 * //ww w  .  j  a  v a2s  .c o m
 *
 * @param dir - 
 * @param file - 
 * @return ?
 */
public static String join(String dir, String file) {
    return (dir.endsWith(File.separator) ? dir : dir + File.separator)
            + (file.startsWith(File.separator) ? file.substring(1) : file);
}