java.lang.String.toLowerCase()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(282)

本文整理了Java中java.lang.String.toLowerCase()方法的一些代码示例,展示了String.toLowerCase()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。String.toLowerCase()方法的具体详情如下:
包路径:java.lang.String
类名称:String
方法名:toLowerCase

String.toLowerCase介绍

[英]Converts all of the characters in this String to lower case using the rules of the default locale. This is equivalent to calling toLowerCase(Locale.getDefault()).

Note: This method is locale sensitive, and may produce unexpected results if used for strings that are intended to be interpreted locale independently. Examples are programming language identifiers, protocol keys, and HTML tags. For instance, "TITLE".toLowerCase() in a Turkish locale returns "t\u005Cu0131tle", where '\u005Cu0131' is the LATIN SMALL LETTER DOTLESS I character. To obtain correct results for locale insensitive strings, use toLowerCase(Locale.ENGLISH).
[中]使用默认区域设置的规则将此String中的所有字符转换为小写。这相当于调用toLowerCase(Locale.getDefault())
注意:此方法对区域设置敏感,如果用于要独立于区域设置进行解释的字符串,则可能会产生意外结果。例如编程语言标识符、协议密钥和HTML标记。例如,在土耳其语言环境中,"TITLE".toLowerCase()返回"t\u005Cu0131tle",其中“\u005Cu0131”是拉丁文小写字母DOTLESS I字符。要获得不区分区域设置的字符串的正确结果,请使用toLowerCase(Locale.ENGLISH)

代码示例

代码示例来源:origin: ReactiveX/RxJava

public static String timeoutMessage(long timeout, TimeUnit unit) {
  return "The source did not signal an event for "
      + timeout
      + " "
      + unit.toString().toLowerCase()
      + " and has been terminated.";
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Determine whether the given URL points to a jar file itself,
 * that is, has protocol "file" and ends with the ".jar" extension.
 * @param url the URL to check
 * @return whether the URL has been identified as a JAR file URL
 * @since 4.1
 */
public static boolean isJarFileURL(URL url) {
  return (URL_PROTOCOL_FILE.equals(url.getProtocol()) &&
      url.getPath().toLowerCase().endsWith(JAR_FILE_EXTENSION));
}

代码示例来源:origin: spring-projects/spring-framework

private int getPort(URI uri) {
  if (uri.getPort() == -1) {
    String scheme = uri.getScheme().toLowerCase(Locale.ENGLISH);
    return ("wss".equals(scheme) ? 443 : 80);
  }
  return uri.getPort();
}

代码示例来源:origin: square/okhttp

public Challenge(String scheme, Map<String, String> authParams) {
 if (scheme == null) throw new NullPointerException("scheme == null");
 if (authParams == null) throw new NullPointerException("authParams == null");
 this.scheme = scheme;
 Map<String, String> newAuthParams = new LinkedHashMap<>();
 for (Entry<String, String> authParam : authParams.entrySet()) {
  String key = (authParam.getKey() == null) ? null : authParam.getKey().toLowerCase(US);
  newAuthParams.put(key, authParam.getValue());
 }
 this.authParams = unmodifiableMap(newAuthParams);
}

代码示例来源:origin: google/guava

@Override
 public String apply(String input) {
  return input.toLowerCase();
 }
});

代码示例来源:origin: spring-projects/spring-framework

private void updateContentTypeHeader() {
  if (this.contentType != null) {
    StringBuilder sb = new StringBuilder(this.contentType);
    if (!this.contentType.toLowerCase().contains(CHARSET_PREFIX) && this.charset) {
      sb.append(";").append(CHARSET_PREFIX).append(this.characterEncoding);
    }
    doAddHeaderValue(HttpHeaders.CONTENT_TYPE, sb.toString(), true);
  }
}

代码示例来源:origin: spring-projects/spring-framework

private boolean isDisconnectedClientError(Throwable ex)  {
  String message = NestedExceptionUtils.getMostSpecificCause(ex).getMessage();
  message = (message != null ? message.toLowerCase() : "");
  String className = ex.getClass().getSimpleName();
  return (message.contains("broken pipe") || DISCONNECTED_CLIENT_EXCEPTIONS.contains(className));
}

代码示例来源:origin: spring-projects/spring-framework

private boolean indicatesDisconnectedClient(Throwable ex)  {
  String message = NestedExceptionUtils.getMostSpecificCause(ex).getMessage();
  message = (message != null ? message.toLowerCase() : "");
  String className = ex.getClass().getSimpleName();
  return (message.contains("broken pipe") || DISCONNECTED_CLIENT_EXCEPTIONS.contains(className));
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * Convert the given key to a case-insensitive key.
 * <p>The default implementation converts the key
 * to lower-case according to this Map's Locale.
 * @param key the user-specified key
 * @return the key to use for storing
 * @see String#toLowerCase(Locale)
 */
protected String convertKey(String key) {
  return key.toLowerCase(getLocale());
}

代码示例来源:origin: spring-projects/spring-framework

@Override
public int hashCode() {
  int result = (isCaseSensitiveName() ? this.name.hashCode() : this.name.toLowerCase().hashCode());
  result = 31 * result + (this.value != null ? this.value.hashCode() : 0);
  result = 31 * result + (this.isNegated ? 1 : 0);
  return result;
}

代码示例来源: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

@Override
  public String[] resolve(Class<?> testClass) {
    return new String[] { testClass.getSimpleName().toLowerCase() };
  }
}

代码示例来源:origin: square/okhttp

/** Returns true if {@code certificate} matches {@code hostname}. */
private boolean verifyHostname(String hostname, X509Certificate certificate) {
 hostname = hostname.toLowerCase(Locale.US);
 List<String> altNames = getSubjectAltNames(certificate, ALT_DNS_NAME);
 for (String altName : altNames) {
  if (verifyHostname(hostname, altName)) {
   return true;
  }
 }
 return false;
}

代码示例来源:origin: spring-projects/spring-framework

private Token eatToken(TokenKind expectedKind) {
  Token t = nextToken();
  if (t == null) {
    int pos = this.expressionString.length();
    throw internalException(pos, SpelMessage.OOD);
  }
  if (t.kind != expectedKind) {
    throw internalException(t.startPos, SpelMessage.NOT_EXPECTED_TOKEN,
        expectedKind.toString().toLowerCase(), t.getKind().toString().toLowerCase());
  }
  return t;
}

代码示例来源:origin: ReactiveX/RxJava

File directoryOf(String baseClassName) throws Exception {
  File f = MaybeNo2Dot0Since.findSource("Flowable");
  if (f == null) {
    return null;
  }
  String parent = f.getParentFile().getAbsolutePath().replace('\\', '/');
  if (!parent.endsWith("/")) {
    parent += "/";
  }
  parent += "internal/operators/" + baseClassName.toLowerCase() + "/";
  return new File(parent);
}

代码示例来源:origin: spring-projects/spring-framework

@Test
public void test() {
  assertTrue(Arrays.asList(applicationContext.getEnvironment().getActiveProfiles()).contains(
    getClass().getSimpleName().toLowerCase()));
}

代码示例来源:origin: spring-projects/spring-framework

private Method getMethodForHttpStatus(HttpStatus status) throws NoSuchMethodException {
  String name = status.name().toLowerCase().replace("_", "-");
  name = "is" + StringUtils.capitalize(Conventions.attributeNameToPropertyName(name));
  return StatusResultMatchers.class.getMethod(name);
}

代码示例来源:origin: spring-projects/spring-framework

private void testTransportUrl(String scheme, String expectedScheme, TransportType transportType) throws Exception {
  SockJsUrlInfo info = new SockJsUrlInfo(new URI(scheme + "://example.com"));
  String serverId = info.getServerId();
  String sessionId = info.getSessionId();
  String transport = transportType.toString().toLowerCase();
  URI expected = new URI(expectedScheme + "://example.com/" + serverId + "/" + sessionId + "/" + transport);
  assertThat(info.getTransportUrl(transportType), equalTo(expected));
}

代码示例来源:origin: spring-projects/spring-framework

@Test
@EnabledOnMac
void enabledIfWithSpelOsCheckInCustomComposedAnnotation() {
  String os = System.getProperty("os.name").toLowerCase();
  assertTrue(os.contains("mac"), "This test must be enabled on Mac OS");
  assertFalse(os.contains("win"), "This test must be disabled on Windows");
}

相关文章