java.lang.StringBuffer.trimToSize()方法的使用及代码示例

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

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

StringBuffer.trimToSize介绍

暂无

代码示例

代码示例来源:origin: sharneng/gm4java

private String getGMOutput() {
  int size = sb.length() - EOL_SIZE;
  if (size > 0) sb.setLength(size);
  String output = sb.toString();
  if (sb.length() > NORMAL_BUFFER_SIZE) {
    sb.setLength(0);
    sb.trimToSize();
  }
  return output;
}

代码示例来源:origin: xyz.cofe/common

/**
 * Скидывает содежимое всего стека в основной writer, в той же последовательности что и соот. вызовы write(...)
 * @throws IOException Ошибка IO
 */
@Override
public void flush() throws IOException {
  output.flush();
  if( stack.size()>0 ){
    Writer w = output;
    for( int i=stack.size()-1; i>=0; i-- ){
      Writer top = stack.get(i);
      if( w instanceof StringWriter ){
        StringWriter sw = (StringWriter)w;
        sw.flush();
        String buff = sw.toString();
        top.write(buff);
        
        sw.getBuffer().setLength(0);
        sw.getBuffer().trimToSize();
      }
      w = top;
    }
  }
}

代码示例来源:origin: jboss-switchyard/release

@Override
public XAResource[] getXAResources(ActivationSpec[] arg0)
    throws ResourceException {
  StringBuffer buffer = new StringBuffer();
  for (ActivationSpec as : arg0) {
    buffer.append("[" + as.toString() + "] ");
  }
  buffer.trimToSize();
  _logger.debug("call getXAResources(" + buffer.toString() + ")");
  return null;
}

代码示例来源:origin: Vhati/Slipstream-Mod-Manager

buf.setLength( 0 );
buf.trimToSize();  // Free the buffer.
buf = null;

相关文章