List of usage examples for java.lang String indexOf
public int indexOf(String str)
From source file:Main.java
/** * Returns the scheme prefix like "http" from the URL spec, or null if the * spec doesn't start with a scheme. Scheme prefixes match this pattern: * {@code alpha ( alpha | digit | '+' | '-' | '.' )* ':'} *///from w w w. j av a 2s . c o m public static String getSchemePrefix(String spec) { int colon = spec.indexOf(':'); if (colon < 1) { return null; } for (int i = 0; i < colon; i++) { char c = spec.charAt(i); if (!isValidSchemeChar(i, c)) { return null; } } return spec.substring(0, colon).toLowerCase(Locale.US); }
From source file:Main.java
public static String findEncoding(final String xml) { final int encodingIndexStart = xml.indexOf(ENCODING_START); final int firstLineBreak = xml.indexOf("\n"); // make sure we found the encoding attribute if (encodingIndexStart != -1) { final int encodingIndexEnd = xml.indexOf("\"", encodingIndexStart + ENCODING_START.length()); // make sure the encoding attribute was found before the first // line break if (firstLineBreak == -1 || encodingIndexStart < firstLineBreak) { // make sure we found the end of the attribute if (encodingIndexEnd != -1) { return xml.substring(encodingIndexStart + ENCODING_START.length(), encodingIndexEnd); }/* w ww .j av a 2 s . co m*/ } } return null; }
From source file:Main.java
public static int indexOfEnhanced(String src, String... strs) { for (String s : strs) { if (src.indexOf(s) != -1) return src.indexOf(s); }/*www. j a v a 2s .c om*/ return -1; }
From source file:Main.java
public static float transformPercentToFloat(String formatString) { float floatResult = Float.valueOf((formatString.substring(0, formatString.indexOf("%")))) / 100; return floatResult; }
From source file:no.digipost.api.useragreements.client.filters.request.RequestToSign.java
static String queryParametersFromURI(String uri) { int index = uri.indexOf('?'); return index == -1 ? "" : uri.substring(index + 1); }
From source file:Main.java
private static Pair<Integer, Integer> rankPosition(String taxon) { int i = taxon.indexOf("subsp."); if (i < 0) { i = taxon.indexOf("form."); if (i < 0) { i = taxon.indexOf("var."); if (i < 0) { return new Pair<Integer, Integer>(-1, -1); } else { return new Pair<Integer, Integer>(i, 4); }// w w w. j a va2 s. co m } else { return new Pair<Integer, Integer>(i, 5); } } else { return new Pair<Integer, Integer>(i, 6); } }
From source file:edu.duke.cabig.c3pr.utils.web.C3PRWebUtils.java
public static int indexOf(String stringToBeManipulated, char token) { return stringToBeManipulated.indexOf(token); }
From source file:Main.java
public static String[] splitLabelAndValue(String str, String expr) { String[] strs = null;/*from w w w. j a v a 2 s . c o m*/ if (str != null && str.indexOf(expr) > 0) { strs = str.split(expr); } return strs; }
From source file:Main.java
/** * Given a uri that represents a qualified name, tries to * determine the index of the split point between the namespace * and the local name. Returns the last index of #, /, or :, * checking for each. If the string contains no :, it doesn't count * as a uri and nothing is returned.//from www . j av a2 s. c o m * @param uri the uri * @return the split point, or -1 if not found */ public static int getQNameSplitPoint(String uri) { int col = uri.indexOf(":"); if (col < 0) { return -1; } else { int hash = uri.indexOf("#"); if (hash < 0) { int slash = Math.max(uri.lastIndexOf("/"), uri.lastIndexOf("\\")); if (slash > 0) { return slash; } else { return col; } } else { return hash; } } }
From source file:Main.java
/** * Strips the leading path up to "config". * @param file the file //from w ww . j a va 2s . c o m * @return the full path after and including the config */ protected static String getRelativeName(final File file) { String absName = file.getAbsolutePath(); int inx = absName.indexOf("config"); if (inx != -1) { return absName.substring(inx, absName.length()); } return null; }