List of usage examples for java.lang String endsWith
public boolean endsWith(String suffix)
From source file:info.magnolia.importexport.BootstrapFilesComparator.java
private static String getName(File file) { String name = StringUtils.substringBeforeLast(file.getName(), "."); if (name.endsWith(DataTransporter.XML) || name.endsWith(DataTransporter.PROPERTIES)) { name = StringUtils.substringBeforeLast(file.getName(), "."); }/* w ww . j a v a 2s .co m*/ return name; }
From source file:ru.bozaro.protobuf.client.ProtobufClient.java
@NotNull public static URI prepareUrl(@NotNull URI url) { final String path = url.getPath(); return path == null || path.endsWith("/") ? url : url.resolve(path + "/"); }
From source file:Main.java
/** * Determines if this is a quoted argumented - either single or * double quoted.// w ww . java 2 s.c om * * @param argument the argument to check * @return true when the argument is quoted */ public static boolean isQuoted(final String argument) { return (argument.startsWith(SINGLE_QUOTE) || argument.startsWith(DOUBLE_QUOTE)) && (argument.endsWith(SINGLE_QUOTE) || argument.endsWith(DOUBLE_QUOTE)); }
From source file:Main.java
/** * Return whether the given mediatype is considered as XML. * * TODO: This does test on the mediatype only, but we need one to check the content type as well for the case * "text/html; charset=foobar"/* ww w . j a v a2s. c o m*/ * * @param mediatype mediatype or null * @return true if not null and XML mediatype, false otherwise */ public static boolean isXMLMediatype(String mediatype) { return mediatype != null && (mediatype.equals(XML_CONTENT_TYPE1) || mediatype.equals(XML_CONTENT_TYPE2) || mediatype.endsWith(XML_CONTENT_TYPE3_SUFFIX)); }
From source file:Main.java
/** * Remove the leading and trailing quotes from <code>str</code>. * E.g. if str is '"one two"', then 'one two' is returned. * * @param str The string from which the leading and trailing quotes * should be removed.//from w w w. ja v a2 s .com * * @return The string without the leading and trailing quotes. */ static String stripLeadingAndTrailingQuotes(String str) { if (str.startsWith("\"")) { str = str.substring(1, str.length()); } if (str.endsWith("\"")) { str = str.substring(0, str.length() - 1); } return str; }
From source file:Main.java
/** * @param filePath filePath example("pictures") *//* www .j a va2 s .c o m*/ public static List<String> traversalAssetsFiles(Context context, String filePath) { List<String> files = new ArrayList<>(); try { for (String file : context.getAssets().list(filePath)) { if (file != null && !file.isEmpty()) { if (file.endsWith(".jpg") || file.endsWith(".gif") || file.endsWith(".png")) { files.add(file); } } } } catch (IOException e) { e.printStackTrace(); } return files; }
From source file:Main.java
/** * Creates a FileFilter for a specified description * and an array of allowed extensions. <br /> * // w w w .ja v a2 s . c o m * @param extensions the allowed extensions without a dot * @param description the displayed description * @return the created FileFilter */ public static FileFilter createFilter(final String[] extensions, final String description) { return new FileFilter() { @Override public boolean accept(File file) { if (file.isDirectory()) { return true; } String name = file.getName().toLowerCase(); for (String e : extensions) { if (name.endsWith("." + e.toLowerCase())) { return true; } } return false; } @Override public String getDescription() { return description; } }; }
From source file:com.fizzed.stork.launcher.FileUtil.java
static public List<File> findFiles(String fileString, boolean ignoreNonExistent) throws IOException { if (fileString.endsWith("*")) { // file string contains a glob... File f = new File(fileString); File parent = f.getParentFile(); if (parent == null) { parent = new File("."); }/*from w w w.j a v a 2 s. co m*/ FileFilter fileFilter = new WildcardFileFilter(f.getName()); File[] files = parent.listFiles(fileFilter); return Arrays.asList(files); } else { File f = new File(fileString); if (!f.exists()) { if (ignoreNonExistent) { return Collections.EMPTY_LIST; } else { throw new IOException("File [" + fileString + "] does not exist"); } } else { if (f.isDirectory()) { return Arrays.asList(f.listFiles()); } else { return Arrays.asList(f); } } } }
From source file:Main.java
public static String getLangCode() { String lang_code = Locale.getDefault().toString(); if (!TextUtils.isEmpty(lang_code)) { if (lang_code.startsWith("zh") && !lang_code.endsWith("CN")) { lang_code = "zh_TW"; }/*from ww w. j a va 2s .co m*/ if (lang_code.startsWith("en")) { lang_code = "en_US"; } } else { lang_code = "zh_CN"; } return lang_code; }
From source file:Main.java
private static String escapeWifiName(String wifiName) { if (TextUtils.isEmpty(wifiName)) return ""; if (Build.VERSION.SDK_INT >= 17 && wifiName.startsWith("\"") && wifiName.endsWith("\"")) { wifiName = wifiName.substring(1, wifiName.length() - 1); }/*ww w . jav a2s . c o m*/ return wifiName; }