Tabnine Logo
StringBuilder.trimToSize
Code IndexAdd Tabnine to your IDE (free)

How to use
trimToSize
method
in
java.lang.StringBuilder

Best Java code snippets using java.lang.StringBuilder.trimToSize (Showing top 20 results out of 738)

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;
}
java.langStringBuildertrimToSize

Popular methods of StringBuilder

  • append
  • toString
  • <init>
    Constructs a string builder initialized to the contents of the specified string. The initial capacit
  • length
  • setLength
  • charAt
  • deleteCharAt
  • insert
  • substring
  • delete
  • replace
  • setCharAt
  • replace,
  • setCharAt,
  • indexOf,
  • lastIndexOf,
  • reverse,
  • appendCodePoint,
  • getChars,
  • subSequence,
  • ensureCapacity

Popular in Java

  • Making http post requests using okhttp
  • scheduleAtFixedRate (Timer)
  • getSupportFragmentManager (FragmentActivity)
  • notifyDataSetChanged (ArrayAdapter)
  • File (java.io)
    An "abstract" representation of a file system entity identified by a pathname. The pathname may be a
  • SocketException (java.net)
    This SocketException may be thrown during socket creation or setting options, and is the superclass
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • JLabel (javax.swing)
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • DateTimeFormat (org.joda.time.format)
    Factory that creates instances of DateTimeFormatter from patterns and styles. Datetime formatting i
  • Top plugins for WebStorm
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