List of usage examples for java.lang String endsWith
public boolean endsWith(String suffix)
From source file:net.orfjackal.dimdwarf.server.ApplicationLoader.java
private static File[] listJarsInDirectory(File dir) { return dir.listFiles(new FilenameFilter() { public boolean accept(File dir, String name) { return name.endsWith(".jar"); }//from w ww . j av a2s. c om }); }
From source file:Utils.java
public static String quote(String str) { if (str == null) return str; if (str.length() < 2 || !str.startsWith("\"") || !str.endsWith("\"")) str = "\"" + str + "\""; return str;// w ww . j av a 2 s. c o m }
From source file:Main.java
public static File[] listBackups(File backupPath) { if (!backupPath.isDirectory() || !backupPath.canRead()) { return new File[0]; }//w w w.j a v a 2s . c om File[] files = backupPath.listFiles(new FilenameFilter() { @Override public boolean accept(File dir, String filename) { return (new File(dir, filename)).isFile() && filename.endsWith(".backup"); } }); if (files != null) { Arrays.sort(files, new Comparator<File>() { @Override public int compare(File s1, File s2) { return s2.getName().compareTo(s1.getName()); } }); return files; } else { return new File[0]; } }
From source file:Main.java
public static String getDomainFromUri(String domain) { if (domain.indexOf("//") > -1) domain = domain.substring(domain.indexOf("//") + 2); if (domain.endsWith("/")) domain = domain.substring(0, domain.indexOf("/")); if (domain.contains(":")) domain = domain.substring(0, domain.indexOf(":")); return domain; }
From source file:com.github.mjeanroy.junit.servers.samples.jetty.java.IndexWithRunnerTest.java
@TestServerConfiguration private static EmbeddedJettyConfiguration configuration() throws Exception { String current = new File(".").getCanonicalPath(); if (!current.endsWith("/")) { current += "/"; }//from www . jav a 2s.c o m String subProjectPath = "samples/spring-java-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.java.IndexWithRunnerTest.java
@TestServerConfiguration private static EmbeddedTomcatConfiguration configuration() throws Exception { String current = new File(".").getCanonicalPath(); if (!current.endsWith("/")) { current += "/"; }// w ww . ja v a 2 s . c om String subProjectPath = "samples/spring-java-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:org.trustedanalytics.servicebroker.gearpump.service.externals.helpers.HdfsUtils.java
public static String ensureTrailingSlash(String text) { return text + (text.endsWith("/") ? "" : "/"); }
From source file:Main.java
public static boolean mayBeJson(String string) { return !isNullEmptyOrWhitespace(string) && ("null".equals(string) || (string.startsWith("[") && string.endsWith("]")) || (string.startsWith("{") && string.endsWith("}"))); }
From source file:ca.weblite.xmlvm.XmlvmHelper.java
public static void runXmlvm(Project project, Path xmlvmClasspath, String[] args) { Path path = new Path(project, System.getProperty("java.class.path")); if (xmlvmClasspath != null) { path.add(xmlvmClasspath);/* w ww .ja va 2 s. c o m*/ } System.out.println("Checking classpath for xmlvm.jar: " + path); String xmlvm = null; for (String p : path.list()) { if (p.equals("xmlvm.jar") || p.endsWith(File.separator + "xmlvm.jar")) { xmlvm = p; } } if (xmlvm == null) { throw new RuntimeException("Could not find XMLVM "); } runXmlvm(project, args, new File(xmlvm)); }
From source file:io.github.azige.mages.Util.java
static List<Plugin> loadPluginsFromDirectory(File dir) { List<Plugin> list = new LinkedList<>(); File[] files = dir.listFiles(new FilenameFilter() { @Override//from w w w . j a v a 2s . c o m public boolean accept(File dir, String name) { return name.endsWith(".groovy"); } }); if (files == null) { return list; } try { GroovyClassLoader loader = new GroovyClassLoader(); loader.addClasspath(dir.getCanonicalPath()); final int extLength = ".groovy".length(); for (File f : files) { String name = f.getName(); String script = FileUtils.readFileToString(f, "UTF-8"); list.add(wrapPlugin(name.substring(0, name.length() - extLength), loader.parseClass(script).newInstance())); } } catch (Exception ex) { throw new MagesException(ex); } return list; }