List of usage examples for java.lang String endsWith
public boolean endsWith(String suffix)
From source file:Main.java
public static boolean isZh(Context context) { Locale locale = context.getResources().getConfiguration().locale; String language = locale.getLanguage(); if (language.endsWith("zh")) return true; else//from ww w . j a va 2 s . com return false; }
From source file:Main.java
public static String getOnePointDouble(double d) { if (d == 0)// www . ja va2s . c o m return "0.0"; try { DecimalFormat df = new DecimalFormat("######0.0"); String text = df.format(d); if (text.endsWith("0")) return text.substring(0, text.length() - 1); return text; } catch (Exception e) { return "0.0"; } }
From source file:Main.java
private static boolean isIndex(String indexString) { return indexString.startsWith("[") && indexString.endsWith("]"); }
From source file:Main.java
public static boolean isEN(Context context) { Locale locale = context.getResources().getConfiguration().locale; String language = locale.getLanguage(); if (language.endsWith("en")) { return true; }//from w ww. j a v a2s .c o m return false; }
From source file:Main.java
public static String map2Str(Map<String, String> map) { StringBuilder sb = new StringBuilder(""); Set<String> keys = map.keySet(); for (String key : keys) sb.append(key + ":" + map.get(key) + ", "); String s = sb.toString().trim(); if (!s.endsWith(",")) return s; else/*www. j ava 2s.c o m*/ return s.substring(0, s.lastIndexOf(",") - 1); }
From source file:Main.java
static boolean isDefault(final String category) { return category.endsWith("*"); }
From source file:Main.java
/** * Excel sometimes adds mysterious formatting to CSV files. * This function tries to clean it up.//from w w w . j a v a2 s . c o m * * @param line line from AIMLIF file * @return reformatted line */ public static String fixCSV(String line) { while (line.endsWith(";")) line = line.substring(0, line.length() - 1); if (line.startsWith("\"")) line = line.substring(1, line.length()); if (line.endsWith("\"")) line = line.substring(0, line.length() - 1); line = line.replaceAll("\"\"", "\""); return line; }
From source file:Main.java
public static long sizeFromMToLong(String sizeString) { long size = 0; if (sizeString.endsWith("M")) { sizeString = sizeString.substring(0, sizeString.length() - 1); size = (long) ((Double.valueOf(sizeString)) * 1024 * 1024); } else if (sizeString.endsWith("K")) { sizeString = sizeString.substring(0, sizeString.length() - 1); size = (long) ((Double.valueOf(sizeString)) * 1024); }//w ww . j a v a 2 s.c om return size; }
From source file:Main.java
public static String stripIndexPhpOrAppsFiles(String url) { String strippedUrl = url; if (strippedUrl.endsWith("/index.php")) { strippedUrl = strippedUrl.substring(0, strippedUrl.lastIndexOf("/index.php")); } else if (strippedUrl.contains("/index.php/apps/")) { strippedUrl = strippedUrl.substring(0, strippedUrl.lastIndexOf("/index.php/apps/")); }// ww w .j a v a2 s. c o m return strippedUrl; }
From source file:Main.java
/** * Removes '[' and ']' from beginning and end of a String, * but only if both are present. //from w ww . j a va 2 s. co m * @param s * @return */ public static String chopBraces(String s) { if (s.startsWith(STRSQBRACKETSTART) && s.endsWith(STRSQBRACKETEND)) return s.substring(1, s.length() - 1); return s; }