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

How to use
substring
method
in
java.lang.String

Best Java code snippets using java.lang.String.substring (Showing top 20 results out of 270,720)

origin: square/okhttp

private static String secondaryName(String javaName) {
 if (javaName.startsWith("TLS_")) {
  return "SSL_" + javaName.substring(4);
 } else if (javaName.startsWith("SSL_")) {
  return "TLS_" + javaName.substring(4);
 } else {
  return javaName;
 }
}
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: google/guava

@VisibleForTesting
static String getClassName(String filename) {
 int classNameEnd = filename.length() - CLASS_FILE_NAME_EXTENSION.length();
 return filename.substring(0, classNameEnd).replace('/', '.');
}
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
 Optional<String> chop(String str) {
  if (str.endsWith(suffix)) {
   return Optional.of(str.substring(0, str.length() - suffix.length()));
  } else {
   return Optional.absent();
  }
 }
};
origin: square/okhttp

 @FromJson HttpUrl urlFromJson(String urlString) {
  if (urlString.startsWith("wss:")) urlString = "https:" + urlString.substring(4);
  if (urlString.startsWith("ws:")) urlString = "http:" + urlString.substring(3);
  return HttpUrl.get(urlString);
 }
}
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: google/guava

 private static String firstCharOnlyToUpper(String word) {
  return word.isEmpty()
    ? word
    : Ascii.toUpperCase(word.charAt(0)) + Ascii.toLowerCase(word.substring(1));
 }
}
origin: google/guava

 @Override
 public String apply(String from) {
  return (from.length() == 0) ? from : from.substring(1);
 }
}
origin: google/guava

 @Override
 public String apply(String from) {
  return ((from == null) || "".equals(from)) ? null : from.substring(1);
 }
};
origin: google/guava

String consumeTokenIfPresent(CharMatcher matcher) {
 checkState(hasMore());
 int startPosition = position;
 position = matcher.negate().indexIn(input, startPosition);
 return hasMore() ? input.substring(startPosition, position) : input.substring(startPosition);
}
origin: ReactiveX/RxJava

  @Override
  public Object apply(Integer v) throws Exception {
    return Thread.currentThread().getName().substring(0, 4);
  }
}),
origin: ReactiveX/RxJava

  @Override
  public Object apply(Integer v) throws Exception {
    return Thread.currentThread().getName().substring(0, 4);
  }
})
origin: ReactiveX/RxJava

  @Override
  public Object apply(Integer v) throws Exception {
    return Thread.currentThread().getName().substring(0, 4);
  }
}),
origin: ReactiveX/RxJava

  @Override
  public Object apply(Integer v) throws Exception {
    return Thread.currentThread().getName().substring(0, 4);
  }
}),
origin: ReactiveX/RxJava

  @Override
  public Object apply(Integer v) throws Exception {
    return Thread.currentThread().getName().substring(0, 4);
  }
}),
origin: ReactiveX/RxJava

  @Override
  public Object apply(Integer v) throws Exception {
    return Thread.currentThread().getName().substring(0, 4);
  }
}),
origin: ReactiveX/RxJava

  @Override
  public Object apply(Integer v) throws Exception {
    return Thread.currentThread().getName().substring(0, 4);
  }
}),
origin: ReactiveX/RxJava

  @Override
  public Object apply(Integer v) throws Exception {
    return Thread.currentThread().getName().substring(0, 4);
  }
})
origin: square/okhttp

/** Equivalent to {@code string.substring(pos, limit).trim()}. */
public static String trimSubstring(String string, int pos, int limit) {
 int start = skipLeadingAsciiWhitespace(string, pos, limit);
 int end = skipTrailingAsciiWhitespace(string, start, limit);
 return string.substring(start, end);
}
java.langStringsubstring

Javadoc

Returns a new string that is a substring of this string. The substring begins with the character at the specified index and extends to the end of this string.

Examples:

 
"unhappy".substring(2) returns "happy" 
"Harbison".substring(3) returns "bison" 
"emptiness".substring(9) returns "" (an empty string) 

Popular methods of String

  • equals
  • length
    Returns the number of characters in this string.
  • 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.
  • 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
  • Top plugins for Android Studio
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