List of usage examples for java.lang String indexOf
public int indexOf(String str)
From source file:Main.java
public static boolean isURI(String str) { if (str.indexOf(':') == -1) return false; str = str.toLowerCase(Locale.ENGLISH).trim(); if (!str.startsWith("http://") && !str.startsWith("https://") && !str.startsWith("ftp://")) return false; try {//from w ww .jav a 2 s . co m URI uri = new URI(str); String proto = uri.getScheme(); if (proto == null) return false; if (proto.equals("http") || proto.equals("https") || proto.equals("ftp")) { if (uri.getHost() == null) return false; String path = uri.getPath(); if (path != null) { int len = path.length(); for (int i = 0; i < len; i++) { if ("?<>:*|\"".indexOf(path.charAt(i)) > -1) return false; } } } return true; } catch (Exception ex) { return false; } }
From source file:Main.java
private static Node actualFindNode(Node node, String name) { String nodeName = node.getNodeName(); nodeName = nodeName.substring((nodeName.indexOf(":") != -1 ? nodeName.indexOf(":") + 1 : 0)); if (nodeName.equals(name)) { return node; }// w w w .ja va2 s .com if (node.hasChildNodes()) { NodeList list = node.getChildNodes(); int size = list.getLength(); for (int i = 0; i < size; i++) { Node found = actualFindNode(list.item(i), name); if (found != null) return found; } } return null; }