本文整理了Java中java.lang.StringBuilder.trimToSize()
方法的一些代码示例,展示了StringBuilder.trimToSize()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。StringBuilder.trimToSize()
方法的具体详情如下:
包路径:java.lang.StringBuilder
类名称:StringBuilder
方法名:trimToSize
暂无
代码示例来源:origin: netty/netty
public StringBuilder stringBuilder() {
StringBuilder sb = stringBuilder;
if (sb == null) {
return stringBuilder = new StringBuilder(STRING_BUILDER_INITIAL_SIZE);
}
if (sb.capacity() > STRING_BUILDER_MAX_SIZE) {
sb.setLength(STRING_BUILDER_INITIAL_SIZE);
sb.trimToSize();
}
sb.setLength(0);
return sb;
}
代码示例来源:origin: redisson/redisson
public StringBuilder stringBuilder() {
StringBuilder sb = stringBuilder;
if (sb == null) {
return stringBuilder = new StringBuilder(STRING_BUILDER_INITIAL_SIZE);
}
if (sb.capacity() > STRING_BUILDER_MAX_SIZE) {
sb.setLength(STRING_BUILDER_INITIAL_SIZE);
sb.trimToSize();
}
sb.setLength(0);
return sb;
}
代码示例来源:origin: igniterealtime/Openfire
protected void invalidateBuffer() {
if (buffer.length() > 0) {
String str = buffer.substring(startLastMsg);
buffer.delete(0, buffer.length());
buffer.append(str);
buffer.trimToSize();
}
startLastMsg = 0;
}
代码示例来源:origin: skylot/jadx
public void finish() {
removeFirstEmptyLine();
buf.trimToSize();
code = buf.toString();
buf = null;
Iterator<Map.Entry<CodePosition, Object>> it = annotations.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<CodePosition, Object> entry = it.next();
Object v = entry.getValue();
if (v instanceof DefinitionWrapper) {
LineAttrNode l = ((DefinitionWrapper) v).getNode();
l.setDecompiledLine(entry.getKey().getLine());
it.remove();
}
}
}
代码示例来源:origin: wildfly/wildfly
public StringBuilder stringBuilder() {
StringBuilder sb = stringBuilder;
if (sb == null) {
return stringBuilder = new StringBuilder(STRING_BUILDER_INITIAL_SIZE);
}
if (sb.capacity() > STRING_BUILDER_MAX_SIZE) {
sb.setLength(STRING_BUILDER_INITIAL_SIZE);
sb.trimToSize();
}
sb.setLength(0);
return sb;
}
代码示例来源:origin: org.apache.logging.log4j/log4j-api
/**
* Ensures that the char[] array of the specified StringBuilder does not exceed the specified number of characters.
* This method is useful to ensure that excessively long char[] arrays are not kept in memory forever.
*
* @param stringBuilder the StringBuilder to check
* @param maxSize the maximum number of characters the StringBuilder is allowed to have
* @since 2.9
*/
public static void trimToMaxSize(final StringBuilder stringBuilder, final int maxSize) {
if (stringBuilder != null && stringBuilder.capacity() > maxSize) {
stringBuilder.setLength(maxSize);
stringBuilder.trimToSize();
}
}
代码示例来源:origin: prestodb/presto
size = 0;
sb.setLength(0);
sb.trimToSize();
代码示例来源:origin: org.apache.lucene/lucene-analyzers-common
@Override
public void close() throws IOException {
try {
super.close();
} finally {
str.setLength(0);
str.trimToSize();
}
}
代码示例来源:origin: io.netty/netty-common
public StringBuilder stringBuilder() {
StringBuilder sb = stringBuilder;
if (sb == null) {
return stringBuilder = new StringBuilder(STRING_BUILDER_INITIAL_SIZE);
}
if (sb.capacity() > STRING_BUILDER_MAX_SIZE) {
sb.setLength(STRING_BUILDER_INITIAL_SIZE);
sb.trimToSize();
}
sb.setLength(0);
return sb;
}
代码示例来源:origin: com.github.bloodshura/shurax
@Nonnull
public TextBuilder trimToLength() {
builder.trimToSize();
return this;
}
代码示例来源:origin: com.github.bloodshura/ignitium-core
@Nonnull
public TextBuilder clear() {
builder.setLength(0);
builder.trimToSize();
return this;
}
代码示例来源:origin: org.n52.arctic-sea/svalbard
private void fillWithSpaces(StringBuilder sb, int i) {
while (sb.length() < i) {
sb.append(" ");
}
sb.trimToSize();
}
代码示例来源:origin: eclipse/rdf4j
@Override
protected void clear() {
super.clear();
// get rid of anything large left in the buffers.
buffer.setLength(0);
buffer.trimToSize();
languageTagBuffer.setLength(0);
languageTagBuffer.trimToSize();
datatypeUriBuffer.setLength(0);
datatypeUriBuffer.trimToSize();
}
代码示例来源:origin: org.openrdf.sesame/sesame-rio-ntriples
@Override
protected void clear() {
super.clear();
// get rid of anything large left in the buffers.
buffer.setLength(0);
buffer.trimToSize();
languageTagBuffer.setLength(0);
languageTagBuffer.trimToSize();
datatypeUriBuffer.setLength(0);
datatypeUriBuffer.trimToSize();
}
代码示例来源:origin: elki-project/elki
@Override
public void close() throws IOException {
if(reader != null) {
reader.close();
}
buf.setLength(0);
buf.trimToSize();
}
代码示例来源:origin: apache/activemq-artemis
public StringBuilder stringBuilder() {
StringBuilder sb = stringBuilder;
if (sb == null) {
return stringBuilder = new StringBuilder(STRING_BUILDER_INITIAL_SIZE);
}
if (sb.capacity() > STRING_BUILDER_MAX_SIZE) {
sb.setLength(STRING_BUILDER_INITIAL_SIZE);
sb.trimToSize();
}
sb.setLength(0);
return sb;
}
代码示例来源:origin: apache/activemq-artemis
public StringBuilder stringBuilder() {
StringBuilder sb = stringBuilder;
if (sb == null) {
return stringBuilder = new StringBuilder(STRING_BUILDER_INITIAL_SIZE);
}
if (sb.capacity() > STRING_BUILDER_MAX_SIZE) {
sb.setLength(STRING_BUILDER_INITIAL_SIZE);
sb.trimToSize();
}
sb.setLength(0);
return sb;
}
代码示例来源:origin: org.apache.ratis/ratis-proto-shaded
public StringBuilder stringBuilder() {
StringBuilder sb = stringBuilder;
if (sb == null) {
return stringBuilder = new StringBuilder(STRING_BUILDER_INITIAL_SIZE);
}
if (sb.capacity() > STRING_BUILDER_MAX_SIZE) {
sb.setLength(STRING_BUILDER_INITIAL_SIZE);
sb.trimToSize();
}
sb.setLength(0);
return sb;
}
代码示例来源:origin: de.lmu.ifi.dbs.elki/elki
@Override
public void close() throws IOException {
if(reader != null) {
reader.close();
}
buf.setLength(0);
buf.trimToSize();
}
代码示例来源:origin: org.apache.activemq/artemis-jms-client-all
public StringBuilder stringBuilder() {
StringBuilder sb = stringBuilder;
if (sb == null) {
return stringBuilder = new StringBuilder(STRING_BUILDER_INITIAL_SIZE);
}
if (sb.capacity() > STRING_BUILDER_MAX_SIZE) {
sb.setLength(STRING_BUILDER_INITIAL_SIZE);
sb.trimToSize();
}
sb.setLength(0);
return sb;
}
内容来源于网络,如有侵权,请联系作者删除!