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

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

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

StringBuilder.<init>介绍

[英]Constructs an instance with an initial capacity of 16.
[中]构造初始容量为16的实例。

代码示例

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

@Override
 public String toString() {
  StringBuilder description = new StringBuilder("CharMatcher.anyOf(\"");
  for (char c : chars) {
   description.append(showCharacter(c));
  }
  description.append("\")");
  return description.toString();
 }
}

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

@Override
public String replaceFrom(CharSequence sequence, CharSequence replacement) {
 StringBuilder result = new StringBuilder(sequence.length() * replacement.length());
 for (int i = 0; i < sequence.length(); i++) {
  result.append(replacement);
 }
 return result.toString();
}

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

@Override public String toString() {
  StringBuilder result = new StringBuilder();
  result.append(protocol == Protocol.HTTP_1_0 ? "HTTP/1.0" : "HTTP/1.1");
  result.append(' ').append(code);
  if (message != null) {
   result.append(' ').append(message);
  }
  return result.toString();
 }
}

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

private X500Principal buildSubject() {
 StringBuilder nameBuilder = new StringBuilder();
 if (cn != null) {
  nameBuilder.append("CN=").append(cn);
 } else {
  nameBuilder.append("CN=").append(UUID.randomUUID());
 }
 if (ou != null) {
  nameBuilder.append(", OU=").append(ou);
 }
 return new X500Principal(nameBuilder.toString());
}

代码示例来源:origin: stackoverflow.com

private static String getValue(Part part) throws IOException {
  BufferedReader reader = new BufferedReader(new InputStreamReader(part.getInputStream(), "UTF-8"));
  StringBuilder value = new StringBuilder();
  char[] buffer = new char[1024];
  for (int length = 0; (length = reader.read(buffer)) > 0;) {
    value.append(buffer, 0, length);
  }
  return value.toString();
}

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

@Override
  public StringBuilder call() {
    return new StringBuilder();
  }
},

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

@Override
  public StringBuilder call() {
    return new StringBuilder();
  }
},

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

@Override
  public StringBuilder call() {
    return new StringBuilder();
  }
},

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

@Override
  public StringBuilder call() {
    return new StringBuilder();
  }
},

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

@Override
public String toString() {
 StringBuilder builder = new StringBuilder(size() * 5);
 builder.append('[').append(array[start]);
 for (int i = start + 1; i < end; i++) {
  builder.append(", ").append(array[i]);
 }
 return builder.append(']').toString();
}

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

@Override
public String toString() {
 StringBuilder builder = new StringBuilder(size() * 3);
 builder.append('[').append(array[start]);
 for (int i = start + 1; i < end; i++) {
  builder.append(", ").append(array[i]);
 }
 return builder.append(']').toString();
}

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

/**
 * Returns a string containing the string representation of each entry in {@code entries}, using
 * the previously configured separator and key-value separator.
 *
 * @since 11.0
 */
@Beta
public String join(Iterator<? extends Entry<?, ?>> entries) {
 return appendTo(new StringBuilder(), entries).toString();
}

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

/**
 * Returns the RSA private key encoded in <a href="https://tools.ietf.org/html/rfc5208">PKCS
 * #8</a> <a href="https://tools.ietf.org/html/rfc7468">PEM format</a>.
 */
public String privateKeyPkcs8Pem() {
 StringBuilder result = new StringBuilder();
 result.append("-----BEGIN PRIVATE KEY-----\n");
 encodeBase64Lines(result, ByteString.of(keyPair.getPrivate().getEncoded()));
 result.append("-----END PRIVATE KEY-----\n");
 return result.toString();
}

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

@Override public String toString() {
 StringBuilder result = new StringBuilder();
 for (int i = 0, size = size(); i < size; i++) {
  result.append(name(i)).append(": ").append(value(i)).append("\n");
 }
 return result.toString();
}

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

@Override public String toString() {
  if (typeArguments.length == 0) return typeToString(rawType);
  StringBuilder result = new StringBuilder(30 * (typeArguments.length + 1));
  result.append(typeToString(rawType));
  result.append("<").append(typeToString(typeArguments[0]));
  for (int i = 1; i < typeArguments.length; i++) {
   result.append(", ").append(typeToString(typeArguments[i]));
  }
  return result.append(">").toString();
 }
}

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

@Override
  public String apply(Object[] args) {
    StringBuilder b = new StringBuilder();
    for (Object o : args) {
      b.append(o);
    }
    return b.toString();
  }
}).subscribe(ts);

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

public static Part createFormData(String name, @Nullable String filename, RequestBody body) {
 if (name == null) {
  throw new NullPointerException("name == null");
 }
 StringBuilder disposition = new StringBuilder("form-data; name=");
 appendQuotedString(disposition, name);
 if (filename != null) {
  disposition.append("; filename=");
  appendQuotedString(disposition, filename);
 }
 return create(Headers.of("Content-Disposition", disposition.toString()), body);
}

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

static <T> StringBuilder allSequenceFrequency(Map<Integer, List<T>> its) {
  StringBuilder b = new StringBuilder();
  for (Map.Entry<Integer, List<T>> e : its.entrySet()) {
    if (b.length() > 0) {
      b.append(", ");
    }
    b.append(e.getKey()).append("={");
    b.append(sequenceFrequency(e.getValue()));
    b.append("}");
  }
  return b;
}
static <T> StringBuilder sequenceFrequency(Iterable<T> it) {

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

public void testAppendMethods() throws IOException {
 StringBuilder builder = new StringBuilder();
 Writer writer = new AppendableWriter(builder);
 writer.append("Hello,");
 writer.append(' ');
 writer.append("The World Wide Web", 4, 9);
 writer.append("!");
 assertEquals("Hello, World!", builder.toString());
}

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

public void testAsWriter() {
 // Should wrap Appendable in a new object
 Appendable plainAppendable = new StringBuilder();
 Writer result = CharStreams.asWriter(plainAppendable);
 assertNotSame(plainAppendable, result);
 assertNotNull(result);
 // A Writer should not be wrapped
 Appendable secretlyAWriter = new StringWriter();
 result = CharStreams.asWriter(secretlyAWriter);
 assertSame(secretlyAWriter, result);
}

相关文章