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

How to use
trim
method
in
java.lang.String

Best Java code snippets using java.lang.String.trim (Showing top 20 results out of 194,085)

origin: spring-projects/spring-framework

/**
 * Set the namespace URI of the service.
 * Corresponds to the WSDL "targetNamespace".
 */
public void setNamespaceUri(@Nullable String namespaceUri) {
  this.namespaceUri = (namespaceUri != null ? namespaceUri.trim() : null);
}
origin: stackoverflow.com

 public static boolean empty( final String s ) {
 // Null-safe, short-circuit evaluation.
 return s == null || s.trim().isEmpty();
}
origin: square/okhttp

/**
 * Add a field with the specified value without any validation. Only appropriate for headers
 * from the remote peer or cache.
 */
Builder addLenient(String name, String value) {
 namesAndValues.add(name);
 namesAndValues.add(value.trim());
 return this;
}
origin: square/okhttp

public Builder value(String value) {
 if (value == null) throw new NullPointerException("value == null");
 if (!value.trim().equals(value)) throw new IllegalArgumentException("value is not trimmed");
 this.value = value;
 return this;
}
origin: square/okhttp

public Builder name(String name) {
 if (name == null) throw new NullPointerException("name == null");
 if (!name.trim().equals(name)) throw new IllegalArgumentException("name is not trimmed");
 this.name = name;
 return this;
}
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

String toChainString() {
  StringBuilder buf = new StringBuilder();
  PathElement pe = this.head;
  while (pe != null) {
    buf.append(pe.toString()).append(" ");
    pe = pe.next;
  }
  return buf.toString().trim();
}
origin: spring-projects/spring-framework

private static boolean initCacheSectionFlag(String line, @Nullable LineInfo previousLine) {
  if (MANIFEST_SECTION_HEADERS.contains(line.trim())) {
    return line.trim().equals(CACHE_HEADER);
  }
  else if (previousLine != null) {
    return previousLine.isCacheSection();
  }
  throw new IllegalStateException(
      "Manifest does not start with " + MANIFEST_HEADER + ": " + line);
}
origin: spring-projects/spring-framework

Props(Element root) {
  String defaultCache = root.getAttribute("cache");
  this.key = root.getAttribute("key");
  this.keyGenerator = root.getAttribute("key-generator");
  this.cacheManager = root.getAttribute("cache-manager");
  this.condition = root.getAttribute("condition");
  this.method = root.getAttribute(METHOD_ATTRIBUTE);
  if (StringUtils.hasText(defaultCache)) {
    this.caches = StringUtils.commaDelimitedListToStringArray(defaultCache.trim());
  }
}
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: spring-projects/spring-framework

static BeanDefinition parseKeyGenerator(Element element, BeanDefinition def) {
  String name = element.getAttribute("key-generator");
  if (StringUtils.hasText(name)) {
    def.getPropertyValues().add("keyGenerator", new RuntimeBeanReference(name.trim()));
  }
  return def;
}
origin: spring-projects/spring-framework

  @Override
  @Nullable
  public String resolveStringValue(String strVal) throws BeansException {
    String resolved = this.helper.replacePlaceholders(strVal, this.resolver);
    if (trimValues) {
      resolved = resolved.trim();
    }
    return (resolved.equals(nullValue) ? null : resolved);
  }
}
origin: spring-projects/spring-framework

private static void parseErrorHandler(Element element, BeanDefinition def) {
  String name = element.getAttribute("error-handler");
  if (StringUtils.hasText(name)) {
    def.getPropertyValues().add("errorHandler", new RuntimeBeanReference(name.trim()));
  }
}
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: ReactiveX/RxJava

  @Override
  public String apply(String t1) {
    return t1.trim().toLowerCase();
  }
};
origin: ReactiveX/RxJava

  @Override
  public String apply(String t1) {
    return t1.trim().toLowerCase();
  }
};
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

private List<String> splitCookie(String value) {
  List<String> list = new ArrayList<>();
  for (String s : value.split(";")){
    list.add(s.trim());
  }
  return list;
}
origin: spring-projects/spring-framework

/**
 * Parse the {@code class} XML elements.
 */
protected void parseManagedClasses(Element persistenceUnit, SpringPersistenceUnitInfo unitInfo) {
  List<Element> classes = DomUtils.getChildElementsByTagName(persistenceUnit, MANAGED_CLASS_NAME);
  for (Element element : classes) {
    String value = DomUtils.getTextValue(element).trim();
    if (StringUtils.hasText(value)) {
      unitInfo.addManagedClassName(value);
    }
  }
}
origin: spring-projects/spring-framework

@Test
public void noTrim() throws Exception {
  StringArrayPropertyEditor editor = new StringArrayPropertyEditor(",",false,false);
  editor.setAsText("  0,1  , 2 ");
  Object value = editor.getValue();
  String[] array = (String[]) value;
  for (int i = 0; i < array.length; ++i) {
    assertEquals(3, array[i].length());
    assertEquals("" + i, array[i].trim());
  }
  assertEquals("  0,1  , 2 ", editor.getAsText());
}
java.langStringtrim

Javadoc

Returns a copy of the string, with leading and trailing whitespace omitted.

If this String object represents an empty character sequence, or the first and last characters of character sequence represented by this String object both have codes greater than '\u0020' (the space character), then a reference to this String object is returned.

Otherwise, if there is no character with a code greater than '\u0020' in the string, then a new String object representing an empty string is created and returned.

Otherwise, let k be the index of the first character in the string whose code is greater than '\u0020', and let m be the index of the last character in the string whose code is greater than '\u0020'. A new String object is created, representing the substring of this string that begins with the character at index k and ends with the character at index m-that is, the result of this.substring(k, m+1).

This method may be used to trim whitespace (as defined above) from the beginning and end of a string.

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
  • 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 12 Jupyter Notebook extensions
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