List of usage examples for java.lang String indexOf
public int indexOf(String str)
From source file:Main.java
/** * Since "&" in menu text has special meaning, we must escape it before * displaying./*from ww w . j a v a 2 s.c o m*/ * * @param src * Source text. * @return Escaped text. */ public static String getEscapedMenuItemText(String src) { if (src != null && src.indexOf('&') != -1) { src = src.replaceAll("\\&", "&&"); //$NON-NLS-1$ //$NON-NLS-2$ } return src; }
From source file:Main.java
public static void putSumInClass(HashMap<String, Integer> suminclass, String text) { int i = 0, index; String info = text; while ((index = info.indexOf("//@")) > 0) { i++;/*w ww . ja v a 2s. c o m*/ info = info.substring(index + 2); } if (suminclass.get(Integer.toString(i)) == null) { suminclass.put(Integer.toString(i), 1); } else { suminclass.put(Integer.toString(i), suminclass.get(Integer.toString(i)) + 1); } }
From source file:Main.java
public static String parseAction(String action) { return (action.substring(action.indexOf(':') + 1, action.length())).trim(); }
From source file:Main.java
/** * Remove any authorisation details from a URI *///from ww w . j av a 2 s . c o m public static String removeAuthorisation(String uri) { if (uri.indexOf("@") != -1 && (uri.startsWith("ftp://") || uri.startsWith("http://"))) { return uri.substring(0, uri.indexOf(":") + 2) + uri.substring(uri.indexOf("@") + 1); } return uri; }
From source file:Main.java
static String removeNamespace(String xml) { int start = xml.indexOf(" xmlns=\""); int end = xml.indexOf('"', start + "xmlns=\"".length() + 1); if (start != -1) { StringBuilder sb = new StringBuilder(xml.substring(0, start)); sb.append(xml.substring(end + 1)); return sb.toString(); }// w ww .j ava 2 s . c o m return xml; }
From source file:Main.java
public static String substringAfter(String f, String str) { int idx = f.indexOf(str); if (-1 != idx) { return f.substring(idx + str.length()); }//from w w w .ja v a 2 s.c om return null; }
From source file:Main.java
public static boolean hasInvalidCharactor(String value) { String key = value; try {/* w ww . j a v a2s. com*/ if (key.indexOf(";") != -1 || key.indexOf("'") != -1 || key.indexOf("\"") != -1) { return true; } return false; } catch (Exception e) { return true; } }
From source file:Main.java
public static Drawable getImgageDrawable(Context context, String iconStr) { int pos = iconStr.indexOf("."); if (pos != -1) { iconStr = iconStr.substring(0, pos); }/*w ww . j av a 2 s. c om*/ if (!iconCacheHashMap.containsKey(iconStr)) { int res = context.getResources().getIdentifier(iconStr, "drawable", context.getPackageName()); if (res == 0) { return null; } else { Drawable drawable = context.getResources().getDrawable(res); drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight()); iconCacheHashMap.put(iconStr, drawable); } } return iconCacheHashMap.get(iconStr); }
From source file:Main.java
public static String substringBeforeFirst(String string, String delimiter) { final int index = string.indexOf(delimiter); if (index == -1) { return ""; }/*from w w w . j a v a 2 s . c o m*/ return string.substring(0, index); }
From source file:Main.java
public static String getClassName(String classMethodName) { return classMethodName.substring(0, classMethodName.indexOf('#')); }