Tabnine Logo
String.indexOf
Code IndexAdd Tabnine to your IDE (free)

How to use
indexOf
method
in
java.lang.String

Best Java code snippets using java.lang.String.indexOf (Showing top 20 results out of 165,753)

origin: google/guava

 @Override
 public boolean apply(ClassInfo info) {
  return info.className.indexOf('$') == -1;
 }
};
origin: spring-projects/spring-framework

  private int getEndPathIndex(String path) {
    int end = path.indexOf('?');
    int fragmentIndex = path.indexOf('#');
    if (fragmentIndex != -1 && (end == -1 || fragmentIndex < end)) {
      end = fragmentIndex;
    }
    if (end == -1) {
      end = path.length();
    }
    return end;
  }
}
origin: square/okhttp

/**
 * Returns the index of the first character in {@code input} that contains a character in {@code
 * delimiters}. Returns limit if there is no such character.
 */
public static int delimiterOffset(String input, int pos, int limit, String delimiters) {
 for (int i = pos; i < limit; i++) {
  if (delimiters.indexOf(input.charAt(i)) != -1) return i;
 }
 return limit;
}
origin: google/guava

@Override
public int read() throws IOException {
 int readChar;
 do {
  readChar = delegate.read();
 } while (readChar != -1 && toIgnore.indexOf((char) readChar) >= 0);
 return readChar;
}
origin: spring-projects/spring-framework

/**
 * Try to consume the supplied token against the supplied content and update the
 * in comment parse state to the supplied value. Returns the index into the content
 * which is after the token or -1 if the token is not found.
 */
private int commentToken(String line, String token, boolean inCommentIfPresent) {
  int index = line.indexOf(token);
  if (index > - 1) {
    this.inComment = inCommentIfPresent;
  }
  return (index == -1 ? index : index + token.length());
}
origin: spring-projects/spring-framework

private int getQueryIndex(String path) {
  int suffixIndex = path.length();
  int queryIndex = path.indexOf('?');
  if (queryIndex > 0) {
    suffixIndex = queryIndex;
  }
  int hashIndex = path.indexOf('#');
  if (hashIndex > 0) {
    suffixIndex = Math.min(suffixIndex, hashIndex);
  }
  return suffixIndex;
}
origin: spring-projects/spring-framework

private int getEndPathIndex(String lookupPath) {
  int suffixIndex = lookupPath.length();
  int queryIndex = lookupPath.indexOf('?');
  if (queryIndex > 0) {
    suffixIndex = queryIndex;
  }
  int hashIndex = lookupPath.indexOf('#');
  if (hashIndex > 0) {
    suffixIndex = Math.min(suffixIndex, hashIndex);
  }
  return suffixIndex;
}
origin: square/okhttp

/**
 * Returns the next index in {@code input} at or after {@code pos} that contains a character from
 * {@code characters}. Returns the input length if none of the requested characters can be found.
 */
public static int skipUntil(String input, int pos, String characters) {
 for (; pos < input.length(); pos++) {
  if (characters.indexOf(input.charAt(pos)) != -1) {
   break;
  }
 }
 return pos;
}
origin: spring-projects/spring-framework

/**
 * Extract the "raw" bean name from the given (potentially generated) bean name,
 * excluding any "#..." suffixes which might have been added for uniqueness.
 * @param name the potentially generated bean name
 * @return the raw bean name
 * @see #GENERATED_BEAN_NAME_SEPARATOR
 */
public static String originalBeanName(String name) {
  Assert.notNull(name, "'name' must not be null");
  int separatorIndex = name.indexOf(GENERATED_BEAN_NAME_SEPARATOR);
  return (separatorIndex != -1 ? name.substring(0, separatorIndex) : name);
}
origin: square/okhttp

boolean matches(String hostname) {
 if (pattern.startsWith(WILDCARD)) {
  int firstDot = hostname.indexOf('.');
  return (hostname.length() - firstDot - 1) == canonicalHostname.length()
    && hostname.regionMatches(false, firstDot + 1, canonicalHostname, 0,
    canonicalHostname.length());
 }
 return hostname.equals(canonicalHostname);
}
origin: stackoverflow.com

 private static String getSubmittedFileName(Part part) {
  for (String cd : part.getHeader("content-disposition").split(";")) {
    if (cd.trim().startsWith("filename")) {
      String fileName = cd.substring(cd.indexOf('=') + 1).trim().replace("\"", "");
      return fileName.substring(fileName.lastIndexOf('/') + 1).substring(fileName.lastIndexOf('\\') + 1); // MSIE fix.
    }
  }
  return null;
}
origin: square/okhttp

/** Add an header line containing a field name, a literal colon, and a value. */
public Builder add(String line) {
 int index = line.indexOf(":");
 if (index == -1) {
  throw new IllegalArgumentException("Unexpected header: " + line);
 }
 return add(line.substring(0, index).trim(), line.substring(index + 1));
}
origin: google/guava

@Override
public boolean canDecode(CharSequence chars) {
 StringBuilder builder = new StringBuilder();
 for (int i = 0; i < chars.length(); i++) {
  char c = chars.charAt(i);
  if (separator.indexOf(c) < 0) {
   builder.append(c);
  }
 }
 return delegate.canDecode(builder);
}
origin: google/guava

@Override
int decodeTo(byte[] target, CharSequence chars) throws DecodingException {
 StringBuilder stripped = new StringBuilder(chars.length());
 for (int i = 0; i < chars.length(); i++) {
  char c = chars.charAt(i);
  if (separator.indexOf(c) < 0) {
   stripped.append(c);
  }
 }
 return delegate.decodeTo(target, stripped);
}
origin: spring-projects/spring-framework

protected int extractLink(int index, char endChar, String content, Set<ContentChunkInfo> result) {
  int start = index + 1;
  int end = content.indexOf(endChar, start);
  result.add(new ContentChunkInfo(start, end, true));
  return end + 1;
}
origin: spring-projects/spring-framework

public static Method findMethod(String desc, ClassLoader loader) {
  try {
    int lparen = desc.indexOf('(');
    int dot = desc.lastIndexOf('.', lparen);
    String className = desc.substring(0, dot).trim();
    String methodName = desc.substring(dot + 1, lparen).trim();
    return getClass(className, loader).getDeclaredMethod(methodName, parseTypes(desc, loader));
  }
  catch (ClassNotFoundException | NoSuchMethodException ex) {
    throw new CodeGenerationException(ex);
  }
}
origin: spring-projects/spring-framework

public void setTouchy(String touchy) throws Exception {
  if (touchy.indexOf('.') != -1) {
    throw new Exception("Can't contain a .");
  }
  if (touchy.indexOf(',') != -1) {
    throw new NumberFormatException("Number format exception: contains a ,");
  }
  this.touchy = touchy;
}
origin: spring-projects/spring-framework

public static Constructor findConstructor(String desc, ClassLoader loader) {
  try {
    int lparen = desc.indexOf('(');
    String className = desc.substring(0, lparen).trim();
    return getClass(className, loader).getConstructor(parseTypes(desc, loader));
  }
  catch (ClassNotFoundException | NoSuchMethodException ex) {
    throw new CodeGenerationException(ex);
  }
}
origin: spring-projects/spring-framework

@Test
public void testExceptionStackTrace() {
  JMSException jmsEx = new JMSException("could not connect");
  Exception innerEx = new Exception("host not found");
  jmsEx.setLinkedException(innerEx);
  JmsException springJmsEx = JmsUtils.convertJmsAccessException(jmsEx);
  StringWriter sw = new StringWriter();
  PrintWriter out = new PrintWriter(sw);
  springJmsEx.printStackTrace(out);
  String trace = sw.toString();
  assertTrue("inner jms exception not found", trace.indexOf("host not found") > 0);
}
origin: spring-projects/spring-framework

@Test
public void testAdviceUsingJoinPoint() {
  ClassPathXmlApplicationContext bf = newContext("usesJoinPointAspect.xml");
  ITestBean adrian1 = (ITestBean) bf.getBean("adrian");
  adrian1.getAge();
  AdviceUsingThisJoinPoint aspectInstance = (AdviceUsingThisJoinPoint) bf.getBean("aspect");
  //(AdviceUsingThisJoinPoint) Aspects.aspectOf(AdviceUsingThisJoinPoint.class);
  //assertEquals("method-execution(int TestBean.getAge())",aspectInstance.getLastMethodEntered());
  assertTrue(aspectInstance.getLastMethodEntered().indexOf("TestBean.getAge())") != 0);
}
java.langStringindexOf

Javadoc

Returns the index within this string of the first occurrence of the specified character. If a character with value ch occurs in the character sequence represented by this String object, then the index (in Unicode code units) of the first such occurrence is returned. For values of ch in the range from 0 to 0xFFFF (inclusive), this is the smallest value k such that:
 
this.charAt(k) == ch 
is true. For other values of ch, it is the smallest value k such that:
 
this.codePointAt(k) == ch 
is true. In either case, if no such character occurs in this string, then -1 is returned.

Popular methods of String

  • equals
  • length
    Returns the number of characters in this string.
  • substring
    Returns a string containing a subsequence of characters from this string. The returned string shares
  • startsWith
    Compares the specified string to this string, starting at the specified offset, to determine if the
  • format
    Returns a formatted string, using the supplied format and arguments, localized to the given locale.
  • split
    Splits this string using the supplied regularExpression. See Pattern#split(CharSequence,int) for an
  • trim
  • valueOf
    Creates a new string containing the specified characters in the character array. Modifying the chara
  • endsWith
    Compares the specified string to this string to determine if the specified string is a suffix.
  • toLowerCase
    Converts this string to lower case, using the rules of locale.Most case mappings are unaffected by t
  • contains
    Determines if this String contains the sequence of characters in the CharSequence passed.
  • getBytes
  • contains,
  • getBytes,
  • <init>,
  • equalsIgnoreCase,
  • replace,
  • isEmpty,
  • charAt,
  • hashCode,
  • lastIndexOf

Popular in Java

  • Making http requests using okhttp
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • getResourceAsStream (ClassLoader)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • Socket (java.net)
    Provides a client-side TCP socket.
  • TreeSet (java.util)
    TreeSet is an implementation of SortedSet. All optional operations (adding and removing) are support
  • Modifier (javassist)
    The Modifier class provides static methods and constants to decode class and member access modifiers
  • SSLHandshakeException (javax.net.ssl)
    The exception that is thrown when a handshake could not be completed successfully.
  • Servlet (javax.servlet)
    Defines methods that all servlets must implement. A servlet is a small Java program that runs within
  • Github Copilot alternatives
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now