List of usage examples for java.lang String endsWith
public boolean endsWith(String suffix)
From source file:Main.java
public static int numberOfStr(String str, String con) { str = " " + str; if (str.endsWith(con)) { return str.split(con).length; } else {/*from w w w .j av a 2s .c o m*/ return str.split(con).length - 1; } }
From source file:Main.java
/** * Translates a Java file name to a XML file name according * to Android naming convention./*from ww w . jav a 2 s . co m*/ * * Doesn't append .xml extension * * @return XML file name associated with Java file name */ public static String getXmlFileNameFromJavaFileName(String javaFileName) { if (javaFileName.endsWith(".java")) { // cut off ".java" javaFileName = javaFileName.substring(0, javaFileName.length() - 5); } char[] charsJava = javaFileName.toCharArray(); StringBuilder stringBuilder = new StringBuilder(); for (int i = 0; i < charsJava.length; i++) { char currentChar = charsJava[i]; if (Character.isUpperCase(currentChar) && i != 0) { stringBuilder.append('_'); } stringBuilder.append(Character.toLowerCase(currentChar)); } return stringBuilder.toString(); }
From source file:Main.java
public static String stripStartAndEnd(String s, String start, String end) { if (s.startsWith(start) && s.endsWith(end)) return s.substring(start.length(), s.length() - end.length()); else//from ww w. j av a 2s . c o m return s; }
From source file:Main.java
/** * @param s// w w w.j a v a2s .c o m * @return unwrapped text */ public static String unwrapCdata(String s) { return (s.startsWith("<![CDATA[") && s.endsWith("]]>") ? s.substring(9, s.length() - 3).replace("]]]]><![CDATA[>", "]]>") : s); }
From source file:com.orange.cloud.servicebroker.filter.core.service.mapper.SuffixedServiceInstanceBindingRequestMapper.java
protected static String withoutSuffix(String s, String suffix) { return (s.endsWith(suffix) ? s.substring(0, s.length() - suffix.length()) : s); }
From source file:com.asual.summer.onejar.OneJarServer.java
private static String getCurrentWarFile() throws IOException { JarFile jarFile = new JarFile(System.getProperty("java.class.path")); Enumeration<JarEntry> entries = jarFile.entries(); while (entries.hasMoreElements()) { String name = entries.nextElement().getName(); if (name.endsWith(".war")) { File war = new File(new File(System.getProperty("java.io.tmpdir")), "summer-onejar-" + System.currentTimeMillis() + ".war"); InputStream input = jarFile.getInputStream(new ZipEntry(name)); FileOutputStream output = new FileOutputStream(war); IOUtils.copy(input, output); IOUtils.closeQuietly(input); IOUtils.closeQuietly(output); war.deleteOnExit();//from w ww. j a v a 2s .c o m return war.getAbsolutePath(); } } return null; }
From source file:com.cognifide.actions.core.util.Utils.java
public static String slashEnd(String string) { if (string != null && !string.endsWith("/")) { return string + "/"; }//from www . j a v a 2s. c o m return string; }
From source file:Main.java
private static boolean canDeleteWithSuffixInner(String fileName, String suffix) { return suffix == null || suffix.length() <= 0 || fileName.endsWith(suffix); }
From source file:Main.java
public static boolean containsSingle(String str, List<String> list) { for (String s : list) { if (str.endsWith(s)) return true; }//from w w w . j a va2 s . c o m return false; }
From source file:Main.java
public static String form(String name) { if (name.startsWith("\"") && name.endsWith("\"")) { name = name.substring(1, name.length() - 1); }/*from w w w .j a v a2 s . c om*/ if (name.startsWith("'") && name.endsWith("'")) { name = name.substring(1, name.length() - 1); } if (name.startsWith("`") && name.endsWith("`")) { name = name.substring(1, name.length() - 1); } name = name.toLowerCase(); return name; }