List of usage examples for java.lang String indexOf
public int indexOf(String str)
From source file:Main.java
/** * @param source/* www. j a va2 s. c o m*/ * @param name * @return */ private static int getTagPos(String source, String name) { int pos = -1; if (source == null || source.isEmpty() || name == null || name.isEmpty()) return pos; int start; String temp = source; while ((start = temp.indexOf(name)) >= 0) { temp = temp.substring(start); if (temp.charAt(name.length()) == ' ' || temp.charAt(name.length()) == '=') return start; temp = temp.substring(name.length()); } return pos; }
From source file:Main.java
public static String getPathFromImageLoaderFormat(String input) { String header = "file:////"; int index = input.indexOf(header); if (index >= 0) return input.substring(index + header.length()); else// w w w . jav a 2 s . co m return input; }
From source file:Main.java
/** * @comment_sp Saca XMLNamespace//ww w . ja v a 2 s .c o m * @comment_ko removeXMLNamespace * @param source * @return */ public static byte[] removeXMLNamespace(byte source[]) { byte oldContent[] = new byte[source.length]; System.arraycopy(source, 0, oldContent, 0, source.length); String s = new String(oldContent); int startIndex = s.indexOf("xmlns"); int endIndex = s.indexOf(">", startIndex); StringBuffer sb = new StringBuffer(s); sb = sb.delete(startIndex - 1, endIndex); String input = new String(sb); return input.getBytes(); }
From source file:Main.java
public static boolean isExternalURL(String str) { if (str == null) return false; return str.indexOf("http://") == 0 || str.indexOf("https://") == 0 || str.indexOf("www.") == 0; }
From source file:Main.java
/** * change "'aaaa'" to "aaaa"/*ww w .j a va 2 s . c om*/ * * @param str * @return */ public static String removeSingleQuote(String str) { return str.substring(str.indexOf('\'') + 1, str.lastIndexOf('\'')); }
From source file:Main.java
/** * Indicates if the given MIME type is related to XML or not. * <p>// w ww. ja v a 2 s.c o m * XML MIME types : * </p> * <ul> * <li>"<tt>text/xml</tt>",</li> * <li>"<tt>application/xml</tt>",</li> * <li>"<tt>image/svg+xml</tt>",</li> * <li>etc</li> * </ul> * <p> * Non-XML MIME types : * </p> * <ul> * <li>"<tt>application/xml-dtd</tt>",</li> * <li>"<tt>application/xml-external-parsed-entity</tt>",</li> * <li>etc</li> * </ul> * * @param mimeType * The MIME type to test. * @return <code>true</code> if the MIME type contains the string "xml" not * followed by "-", <code>false</code> otherwise. */ public static boolean isXMLMimeType(String mimeType) { int index = mimeType.indexOf("xml"); if (index != -1 && (index + 3 < mimeType.length()) ? mimeType.charAt(index + 3) != '-' : true) { // "application/xml", "text/xml", "image/svg+xml", // "application/xhtml+xml", etc // but not "application/xml-dtd", // "application/xml-external-parsed-entity" etc return true; } else { return false; } }
From source file:Main.java
public static int[] extractTimeDetailsFromString(String value) { int hour = Integer.parseInt(value.substring(0, value.indexOf(COLON))); int min = Integer.parseInt(value.substring(value.indexOf(COLON) + 1, value.length())); return new int[] { hour, min }; }
From source file:Main.java
@SuppressLint("DefaultLocale") public static String getApkStringVerByFileName(String fileName) { String apkVer = null;//from ww w.j ava2 s . c o m try { String s = fileName.toLowerCase(); int i = s.indexOf("ver"); i += 3; if (i + 5 < s.length()) { apkVer = s.substring(i, i + 5); } } catch (Exception e) { e.printStackTrace(); } return apkVer; }
From source file:Main.java
/** Strip the namespace prefix from node name, if any. this allows avoiding the Document strict validation error, that the node should not have prefix when it does not the have associated namespace. * @param nodeName name prefixed as ns:name * @return only 'name' part/* w ww. j a v a 2 s .c om*/ */ public static String removeNsPrefix(final String nodeName) { final int colonAt = nodeName.indexOf(NAMESPACE_PREFIX); if (colonAt >= 0) { return nodeName.substring(colonAt + 1, nodeName.length()); } return nodeName; }
From source file:Main.java
public static List<Element> getSubChildElementList(Element ele, String tagname) { int p0 = tagname.indexOf(':'); if (p0 >= 0) tagname = tagname.substring(p0 + 1); return getSubChildElementList(ele, new String[] { tagname }); }