List of usage examples for java.lang String indexOf
public int indexOf(String str)
From source file:Main.java
public static String d(String paramString) { if ((paramString != null) && (paramString.indexOf(' ') != -1)) paramString = paramString.substring(0, paramString.indexOf(' ')); return paramString; }
From source file:Main.java
public static String getEncoding(String body) { int i = body.indexOf(ENCODING); if (i < 0) { return UTF8; }//w ww . jav a2s . co m i = i + ENCODING.length(); int j = body.indexOf('"', i); if (j < 0) { return UTF8; } return body.substring(i, j); }
From source file:Main.java
/** * Removes the XML Declaration/*from w ww . j a v a 2 s .c o m*/ * * @param text The XML whose declaration is to be removed * * @return String the text of the XML with declaration removed */ public static String removeXMLDeclaration(String text) { int start = text.indexOf("<?xml"); if (start == -1) { return text; } int end = text.indexOf("?>"); return text.substring(end + 2); }
From source file:Main.java
/** * decodeWithoutQuery/* www . java 2 s. c om*/ * * @param uri uri * @return uri */ public static String decodeWithoutQuery(String uri) { int index = uri.indexOf('?'); if (index > 0) { uri = uri.substring(0, index); } return uri; }
From source file:Main.java
/** * This method converts a given XML attribute or element name to a local representation by stripping it of its * namespace prefix.//from w ww. ja v a 2s . c o m * * * @return String * @param xml * - */ public static String getLocalPart(String xml) { final int pos = xml.indexOf(":"); if (pos >= 0) { xml = xml.substring(pos + 1); } return xml; }
From source file:Main.java
/** * Returns the unprefixed name.//from w w w . j a v a 2s .c o m * * @param name the name, with or without a prefix * @return the unprefixed name */ public static String getUnprefixed(String name) { int colonLocation = name.indexOf(':'); return colonLocation == -1 ? name : name.substring(colonLocation + 1); }
From source file:Main.java
public static String getNoExtensionName(String name) { if (name.indexOf(".") == -1) return name; else/* w w w .j a va 2 s . co m*/ return name.substring(0, name.lastIndexOf(getExtension(name)) - 1); }
From source file:Main.java
/** * Extract element.//from w w w . j av a2s .co m * * @param xml * the xml * @param name * the name * @return the string */ public static String extractElement(final String xml, final String name) { if (xml.indexOf("<" + name) > 0) { return xml.substring(xml.indexOf("<" + name), xml.indexOf("</" + name + ">") + name.length() + 3); } return ""; }
From source file:Main.java
public static Document getDocument(String xml) { if (xml == null || xml.indexOf("<?xml") < 0) return null; try {/*from w w w. j a v a2 s.c o m*/ DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(new ByteArrayInputStream(xml.getBytes())); return doc; } catch (Exception e) { e.printStackTrace(); return null; } }
From source file:Main.java
public static String getMethodName(String classMethodName) { return classMethodName.substring(classMethodName.indexOf('#') + 1); }