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

How to use
lastIndexOf
method
in
java.lang.String

Best Java code snippets using java.lang.String.lastIndexOf (Showing top 20 results out of 112,113)

origin: google/guava

/**
 * Returns the package name of {@code classFullName} according to the Java Language Specification
 * (section 6.7). Unlike {@link Class#getPackage}, this method only parses the class name, without
 * attempting to define the {@link Package} and hence load files.
 */
public static String getPackageName(String classFullName) {
 int lastDot = classFullName.lastIndexOf('.');
 return (lastDot < 0) ? "" : classFullName.substring(0, lastDot);
}
origin: spring-projects/spring-framework

/**
 * Unqualify a string qualified by a separator character. For example,
 * "this:name:is:qualified" returns "qualified" if using a ':' separator.
 * @param qualifiedName the qualified name
 * @param separator the separator
 */
public static String unqualify(String qualifiedName, char separator) {
  return qualifiedName.substring(qualifiedName.lastIndexOf(separator) + 1);
}
origin: spring-projects/spring-framework

/**
 * Determine the name of the package of the given fully-qualified class name,
 * e.g. "java.lang" for the {@code java.lang.String} class name.
 * @param fqClassName the fully-qualified class name
 * @return the package name, or the empty String if the class
 * is defined in the default package
 */
public static String getPackageName(String fqClassName) {
  Assert.notNull(fqClassName, "Class name must not be null");
  int lastDotIndex = fqClassName.lastIndexOf(PACKAGE_SEPARATOR);
  return (lastDotIndex != -1 ? fqClassName.substring(0, lastDotIndex) : "");
}
origin: spring-projects/spring-framework

/**
 * Extract the URL filename from the given request URI.
 * @param uri the request URI; for example {@code "/index.html"}
 * @return the extracted URI filename; for example {@code "index"}
 */
protected String extractViewNameFromUrlPath(String uri) {
  int start = (uri.charAt(0) == '/' ? 1 : 0);
  int lastIndex = uri.lastIndexOf('.');
  int end = (lastIndex < 0 ? uri.length() : lastIndex);
  return uri.substring(start, end);
}
origin: spring-projects/spring-framework

/**
 * Determine the name of the class file, relative to the containing
 * package: e.g. "String.class"
 * @param clazz the class
 * @return the file name of the ".class" file
 */
public static String getClassFileName(Class<?> clazz) {
  Assert.notNull(clazz, "Class must not be null");
  String className = clazz.getName();
  int lastDotIndex = className.lastIndexOf(PACKAGE_SEPARATOR);
  return className.substring(lastDotIndex + 1) + CLASS_FILE_SUFFIX;
}
origin: apache/incubator-dubbo

public static String simpleClassName(Class<?> clazz) {
  if (clazz == null) {
    throw new NullPointerException("clazz");
  }
  String className = clazz.getName();
  final int lastDotIdx = className.lastIndexOf(PACKAGE_SEPARATOR_CHAR);
  if (lastDotIdx > -1) {
    return className.substring(lastDotIdx + 1);
  }
  return className;
}
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: spring-projects/spring-framework

@Override
public String extractVersion(String requestPath) {
  Matcher matcher = pattern.matcher(requestPath);
  if (matcher.find()) {
    String match = matcher.group(1);
    return (match.contains("-") ? match.substring(match.lastIndexOf('-') + 1) : match);
  }
  else {
    return null;
  }
}
origin: spring-projects/spring-framework

@Override
@Nullable
public String extractVersion(String requestPath) {
  Matcher matcher = pattern.matcher(requestPath);
  if (matcher.find()) {
    String match = matcher.group(1);
    return (match.contains("-") ? match.substring(match.lastIndexOf('-') + 1) : match);
  }
  else {
    return null;
  }
}
origin: spring-projects/spring-framework

private String getEntityName(Class<?> entityClass) {
  String shortName = ClassUtils.getShortName(entityClass);
  int lastDot = shortName.lastIndexOf('.');
  if (lastDot != -1) {
    return shortName.substring(lastDot + 1);
  }
  else {
    return shortName;
  }
}
origin: google/guava

@Override
public int lastIndexOf(@Nullable Object object) {
 return (object instanceof Character) ? string.lastIndexOf((Character) object) : -1;
}
origin: google/guava

private static @Nullable String convertDottedQuadToHex(String ipString) {
 int lastColon = ipString.lastIndexOf(':');
 String initialPart = ipString.substring(0, lastColon + 1);
 String dottedQuad = ipString.substring(lastColon + 1);
 byte[] quad = textToNumericFormatV4(dottedQuad);
 if (quad == null) {
  return null;
 }
 String penultimate = Integer.toHexString(((quad[0] & 0xff) << 8) | (quad[1] & 0xff));
 String ultimate = Integer.toHexString(((quad[2] & 0xff) << 8) | (quad[3] & 0xff));
 return initialPart + penultimate + ":" + ultimate;
}
origin: apache/incubator-dubbo

public URL setAddress(String address) {
  int i = address.lastIndexOf(':');
  String host;
  int port = this.port;
  if (i >= 0) {
    host = address.substring(0, i);
    port = Integer.parseInt(address.substring(i + 1));
  } else {
    host = address;
  }
  return new URL(protocol, username, password, host, port, path, getParameters());
}
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

private void adaptForwardedHost(String hostToUse) {
  int portSeparatorIdx = hostToUse.lastIndexOf(':');
  if (portSeparatorIdx > hostToUse.lastIndexOf(']')) {
    host(hostToUse.substring(0, portSeparatorIdx));
    port(Integer.parseInt(hostToUse.substring(portSeparatorIdx + 1)));
  }
  else {
    host(hostToUse);
    port(null);
  }
}
origin: apache/incubator-dubbo

private List<URL> toUrlsWithEmpty(URL consumer, String path, List<String> providers) {
  List<URL> urls = toUrlsWithoutEmpty(consumer, providers);
  if (urls == null || urls.isEmpty()) {
    int i = path.lastIndexOf(Constants.PATH_SEPARATOR);
    String category = i < 0 ? path : path.substring(i + 1);
    URL empty = consumer.setProtocol(Constants.EMPTY_PROTOCOL).addParameter(Constants.CATEGORY_KEY, category);
    urls.add(empty);
  }
  return urls;
}
origin: spring-projects/spring-framework

private String getInputTag(String output) {
  int inputStart = output.indexOf("<", 1);
  int inputEnd = output.lastIndexOf(">", output.length() - 2);
  return output.substring(inputStart, inputEnd + 1);
}
origin: spring-projects/spring-framework

private String getFormTag(String output) {
  int inputStart = output.indexOf("<", 1);
  int inputEnd = output.lastIndexOf(">", output.length() - 2);
  return output.substring(0, inputStart) + output.substring(inputEnd + 1);
}
origin: spring-projects/spring-framework

@Nullable
private String decodeAndNormalizePath(@Nullable String path, HttpServletRequest request) {
  if (path != null) {
    path = getUrlPathHelper().decodeRequestString(request, path);
    if (path.charAt(0) != '/') {
      String requestUri = getUrlPathHelper().getRequestUri(request);
      path = requestUri.substring(0, requestUri.lastIndexOf('/') + 1) + path;
      path = StringUtils.cleanPath(path);
    }
  }
  return path;
}
origin: spring-projects/spring-framework

protected final void assertBlockTagContains(String output, String desiredContents) {
  String contents = output.substring(output.indexOf(">") + 1, output.lastIndexOf("<"));
  assertTrue("Expected to find '" + desiredContents + "' in the contents of block tag '" + output + "'",
      contents.contains(desiredContents));
}
java.langStringlastIndexOf

Javadoc

Returns the index within this string of the last occurrence of the specified character. For values of ch in the range from 0 to 0xFFFF (inclusive), the index (in Unicode code units) returned is the largest value k such that:
 
this.charAt(k) == ch 
is true. For other values of ch, it is the largest 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. The String is searched backwards starting at the last character.

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
  • indexOf
  • 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.
  • toLowerCase,
  • contains,
  • getBytes,
  • <init>,
  • equalsIgnoreCase,
  • replace,
  • isEmpty,
  • charAt,
  • hashCode

Popular in Java

  • Parsing JSON documents to java classes using gson
  • onCreateOptionsMenu (Activity)
  • scheduleAtFixedRate (ScheduledExecutorService)
  • onRequestPermissionsResult (Fragment)
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • IOException (java.io)
    Signals a general, I/O-related error. Error details may be specified when calling the constructor, a
  • ResultSet (java.sql)
    An interface for an object which represents a database table entry, returned as the result of the qu
  • MessageFormat (java.text)
    Produces concatenated messages in language-neutral way. New code should probably use java.util.Forma
  • JComboBox (javax.swing)
  • Join (org.hibernate.mapping)
  • Top Vim plugins
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