List of usage examples for java.lang String indexOf
public int indexOf(String str)
From source file:Main.java
public static String getOuterMostClassName() { StackTraceElement[] stackTrace = Thread.currentThread().getStackTrace(); String className = stackTrace[3].getClassName(); int indexOf = className.indexOf("$"); return className.substring(0, indexOf); }
From source file:Main.java
/** * Clean-up the class name// ww w .java 2 s . com * * @param o * @return */ private static String getClassName(Object o) { String className = o.getClass().getName(); int pos = className.indexOf('$'); if (pos != -1) { className = className.substring(0, pos); } return className; }
From source file:Main.java
public static int timeInMS(String time) { int t = 0;/* ww w.j av a 2s. co m*/ int i = time.indexOf("."); int mult = 1000; if (i != -1) { t += mult * Float.parseFloat(time.substring(i)); time = time.substring(0, i); } String[] parts = time.split(":"); for (i = parts.length - 1; i >= 0; i--) { t += Integer.parseInt(parts[i]) * mult; mult *= 60; } return t; }
From source file:Main.java
public static String ArrayToString(String[] values, char delimiter) { String result = ""; int offset = 0; for (String value : values) { if (value.indexOf(delimiter) >= 0) { result += "\"" + value + "\""; } else/*w w w .j a v a 2 s . c o m*/ result += value; offset++; if (offset < values.length) { result += delimiter; } } return result; }
From source file:Main.java
public static String tagNameToFieldName(String tagName) { int minusIndex = tagName.indexOf('-'); while (minusIndex != -1) { char nextChar = tagName.charAt(minusIndex + 1); char upper = Character.toUpperCase(nextChar); StringBuilder sb = new StringBuilder(tagName); sb.replace(minusIndex + 1, minusIndex + 2, new String(new char[] { upper })); sb.replace(minusIndex, minusIndex + 1, ""); tagName = sb.toString();//from w w w . j a va 2 s. c o m minusIndex = tagName.indexOf('-'); } return tagName; }
From source file:Main.java
public static boolean contains(String text, String ch) { if (text != null) { return text.indexOf(ch) > -1; }/*from w w w . j a v a 2s.c o m*/ return false; }
From source file:Main.java
public static String sub(String begin, String end, String src) throws Exception { int indexBegin = src.indexOf(begin); if (indexBegin != -1) { String sub = src.substring(indexBegin + begin.length()); if (end == null) { return sub; }/* w w w . ja va 2s . c om*/ int indexEnd = sub.indexOf(end); if (indexEnd != -1) { return sub.substring(0, indexEnd); } } return null; }
From source file:Main.java
/** * Search for patterns [key=value] and returns the value given the key. * /*www. j ava2 s .co m*/ * @param key * @param string * @return */ public static String lookupParameterValue(String key, String string) { Pattern p = Pattern.compile("\\[" + key + "=[^\\]]*\\]"); Matcher m = p.matcher(string); m.find(); String f = m.group(); int p1 = f.indexOf('='); int p2 = f.indexOf(']'); return f.substring(p1 + 1, p2); }
From source file:Main.java
/** * Extracts category and categoryValue from the mediaID. mediaID is, by this sample's * convention, a concatenation of category (eg "by_genre"), categoryValue (eg "Classical") and * mediaID. This is necessary so we know where the user selected the music from, when the music * exists in more than one music list, and thus we are able to correctly build the playing queue. * * @param mediaID that contains a category and categoryValue. *///from w ww .jav a 2 s.co m public static String[] getHierarchy(String mediaID) { int pos = mediaID.indexOf(LEAF_SEPARATOR); if (pos >= 0) { mediaID = mediaID.substring(0, pos); } return mediaID.split(String.valueOf(CATEGORY_SEPARATOR)); }
From source file:Main.java
public static String getAddressFromBip21String(String addressString) { int bitcoinUriIndex = addressString.indexOf(":"); int paramsIndex = addressString.indexOf("?"); if (bitcoinUriIndex != -1) { // get address from bitcoin uri scheme if (paramsIndex != -1) return addressString.substring(bitcoinUriIndex + 1, paramsIndex); else/*w ww . jav a 2 s . c o m*/ return addressString.substring(bitcoinUriIndex + 1); } else { // not using BIP 21 return addressString; } }