java.lang.StringBuilder.charAt()方法的使用及代码示例

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

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

StringBuilder.charAt介绍

暂无

代码示例

代码示例来源:origin: alibaba/druid

public static long fnv1a_64_lower(StringBuilder key) {
  long hashCode = BASIC;
  for (int i = 0; i < key.length(); ++i) {
    char ch = key.charAt(i);
    if (ch >= 'A' && ch <= 'Z') {
      ch = (char) (ch + 32);
    }
    hashCode ^= ch;
    hashCode *= PRIME;
  }
  return hashCode;
}

代码示例来源:origin: alibaba/druid

public static long fnv1a_64_lower(long basic, StringBuilder key) {
  long hashCode = basic;
  for (int i = 0; i < key.length(); ++i) {
    char ch = key.charAt(i);
    if (ch >= 'A' && ch <= 'Z') {
      ch = (char) (ch + 32);
    }
    hashCode ^= ch;
    hashCode *= PRIME;
  }
  return hashCode;
}

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

public void removeTrailingSlash() {
  int index = this.path.length() - 1;
  if (this.path.charAt(index) == '/') {
    this.path.deleteCharAt(index);
  }
}

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

public static int lineNumber(StringBuilder s, int index) {
  int cnt = 1;
  for (int i = 0; i < index; i++) {
    if (s.charAt(i) == '\n') {
      cnt++;
    }
  }
  return cnt;
}

代码示例来源:origin: org.apache.commons/commons-lang3

private static void convertRemainingAccentCharacters(final StringBuilder decomposed) {
  for (int i = 0; i < decomposed.length(); i++) {
    if (decomposed.charAt(i) == '\u0141') {
      decomposed.deleteCharAt(i);
      decomposed.insert(i, 'L');
    } else if (decomposed.charAt(i) == '\u0142') {
      decomposed.deleteCharAt(i);
      decomposed.insert(i, 'l');
    }
  }
}

代码示例来源:origin: redisson/redisson

@Override
public char lastChar() {
  if ( builder.length() > 0 ) {
    return builder.charAt(builder.length()-1);
  }
  return 0;
}

代码示例来源:origin: greenrobot/greenDAO

public static String dbName(String javaName) {
  StringBuilder builder = new StringBuilder(javaName);
  for (int i = 1; i < builder.length(); i++) {
    boolean lastWasUpper = Character.isUpperCase(builder.charAt(i - 1));
    boolean isUpper = Character.isUpperCase(builder.charAt(i));
    if (isUpper && !lastWasUpper) {
      builder.insert(i, '_');
      i++;
    }
  }
  return builder.toString().toUpperCase();
}

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

/**
 * Trim all occurrences of the supplied leading character from the given {@code String}.
 * @param str the {@code String} to check
 * @param leadingCharacter the leading character to be trimmed
 * @return the trimmed {@code String}
 */
public static String trimLeadingCharacter(String str, char leadingCharacter) {
  if (!hasLength(str)) {
    return str;
  }
  StringBuilder sb = new StringBuilder(str);
  while (sb.length() > 0 && sb.charAt(0) == leadingCharacter) {
    sb.deleteCharAt(0);
  }
  return sb.toString();
}

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

/**
 * Trim leading whitespace from the given {@code String}.
 * @param str the {@code String} to check
 * @return the trimmed {@code String}
 * @see java.lang.Character#isWhitespace
 */
public static String trimLeadingWhitespace(String str) {
  if (!hasLength(str)) {
    return str;
  }
  StringBuilder sb = new StringBuilder(str);
  while (sb.length() > 0 && Character.isWhitespace(sb.charAt(0))) {
    sb.deleteCharAt(0);
  }
  return sb.toString();
}

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

/**
 * Trim all occurrences of the supplied trailing character from the given {@code String}.
 * @param str the {@code String} to check
 * @param trailingCharacter the trailing character to be trimmed
 * @return the trimmed {@code String}
 */
public static String trimTrailingCharacter(String str, char trailingCharacter) {
  if (!hasLength(str)) {
    return str;
  }
  StringBuilder sb = new StringBuilder(str);
  while (sb.length() > 0 && sb.charAt(sb.length() - 1) == trailingCharacter) {
    sb.deleteCharAt(sb.length() - 1);
  }
  return sb.toString();
}

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

/**
 * Trim trailing whitespace from the given {@code String}.
 * @param str the {@code String} to check
 * @return the trimmed {@code String}
 * @see java.lang.Character#isWhitespace
 */
public static String trimTrailingWhitespace(String str) {
  if (!hasLength(str)) {
    return str;
  }
  StringBuilder sb = new StringBuilder(str);
  while (sb.length() > 0 && Character.isWhitespace(sb.charAt(sb.length() - 1))) {
    sb.deleteCharAt(sb.length() - 1);
  }
  return sb.toString();
}

代码示例来源:origin: apache/incubator-druid

private void removeLastComma()
{
 assert sb.charAt(sb.length() - 2) == ',' && sb.charAt(sb.length() - 1) == '\n';
 sb.setCharAt(sb.length() - 2, '\n');
 sb.setLength(sb.length() - 1);
}

代码示例来源:origin: prestodb/presto

private static String convertToAsciiNumber(String convId) {
  StringBuilder buf = new StringBuilder(convId);
  for (int i = 0; i < buf.length(); i++) {
    char ch = buf.charAt(i);
    int digit = Character.digit(ch, 10);
    if (digit >= 0) {
      buf.setCharAt(i, (char) ('0' + digit));
    }
  }
  return buf.toString();
}

代码示例来源:origin: apache/incubator-dubbo

private static String toKey(String prefix, String id) {
  StringBuilder sb = new StringBuilder();
  if (StringUtils.isNotEmpty(prefix)) {
    sb.append(prefix);
  }
  if (StringUtils.isNotEmpty(id)) {
    sb.append(id);
  }
  if (sb.length() > 0 && sb.charAt(sb.length() - 1) != '.') {
    sb.append(".");
  }
  if (sb.length() > 0) {
    return sb.toString();
  }
  return Constants.DUBBO;
}

代码示例来源:origin: apache/incubator-dubbo

private static String toKey(String prefix, String id) {
  StringBuilder sb = new StringBuilder();
  if (StringUtils.isNotEmpty(prefix)) {
    sb.append(prefix);
  }
  if (StringUtils.isNotEmpty(id)) {
    sb.append(id);
  }
  if (sb.length() > 0 && sb.charAt(sb.length() - 1) != '.') {
    sb.append(".");
  }
  if (sb.length() > 0) {
    return sb.toString();
  }
  return Constants.DUBBO;
}

代码示例来源:origin: prestodb/presto

@Override
public void encodeValueInto(int depth, Block block, int position, SliceOutput output)
{
  float value = Float.intBitsToFloat((int) type.getLong(block, position));
  buffer.setLength(0);
  buffer.append(value);
  for (int index = 0; index < buffer.length(); index++) {
    output.writeByte(buffer.charAt(index));
  }
}

代码示例来源:origin: prestodb/presto

@Override
public void encodeValueInto(int depth, Block block, int position, SliceOutput output)
{
  long value = type.getLong(block, position);
  buffer.setLength(0);
  buffer.append(value);
  for (int index = 0; index < buffer.length(); index++) {
    output.writeByte(buffer.charAt(index));
  }
}

代码示例来源:origin: prestodb/presto

private void encodeValue(Block block, int position, SliceOutput output)
{
  double value = type.getDouble(block, position);
  buffer.setLength(0);
  buffer.append(value);
  for (int index = 0; index < buffer.length(); index++) {
    output.writeByte(buffer.charAt(index));
  }
}

代码示例来源:origin: prestodb/presto

private void encodeValue(Block block, int position, SliceOutput output)
{
  long days = type.getLong(block, position);
  long millis = TimeUnit.DAYS.toMillis(days);
  buffer.setLength(0);
  HIVE_DATE_PARSER.printTo(buffer, millis);
  for (int index = 0; index < buffer.length(); index++) {
    output.writeByte(buffer.charAt(index));
  }
}

代码示例来源:origin: prestodb/presto

@Override
public void encodeValueInto(int depth, Block block, int position, SliceOutput output)
{
  long millis = type.getLong(block, position);
  buffer.setLength(0);
  dateTimeFormatter.printTo(buffer, millis);
  for (int index = 0; index < buffer.length(); index++) {
    output.writeByte(buffer.charAt(index));
  }
}

相关文章