Append zeros to a buffer.

@param buf Buffer to append to
@param zeros Number of zeros to append.
@return Buffer
973998
public static StringBuilder appendZeros(StringBuilder buf, int zeros) {
    for(int i = zeros; i > 0; i -= ZEROPADDING.length) {
      buf.append(ZEROPADDING, 0, i < ZEROPADDING.length ? i : ZEROPADDING.length);
    }
    return buf;
  }
1076669
private static <T> StringBuilder appendAllTo(final StringBuilder buf, final String sep, final T... types) {
        Assert.requireNonNullEntries(types, "types");
        Assert.requireNotEmpty(types, "types");
        if (types.length > 0) {
            buf.append(toString(types[0]));
            for (int i = 1; i < types.length; i++) {
                buf.append(sep).append(toString(types[i]));
            }
        }
        return buf;
    }
786821
public void encode(ByteBuf buf) {

        buf.writeByte('*');
        CommandArgs.IntegerArgument.writeInteger(buf, 1 + (args != null ? args.count() : 0));

        buf.writeBytes(CommandArgs.CRLF);

        CommandArgs.BytesArgument.writeBytes(buf, type.getBytes());

        if (args != null) {
            args.encode(buf);
        }
    }
37244
public void addUsageTo(final StringBuilder buf) {
    final ArrayList<String> names = new ArrayList<String>(options.keySet());
    Collections.sort(names);
    int max_length = 0;
    for (final String name : names) {
      final String[] opt = options.get(name);
      final int length = name.length()
        + (opt[0] == null ? 0 : opt[0].length() + 1);
      if (length > max_length) {
        max_length = length;
      }
    }
    for (final String name : names) {
      final String[] opt = options.get(name);
      int length = name.length();
      buf.append("  ").append(name);
      if (opt[0] != null) {
        length += opt[0].length() + 1;
        buf.append('=').append(opt[0]);
      }
      for (int i = length; i <= max_length; i++) {
        buf.append(' ');
      }
      buf.append(opt[1]).append('\n');
    }
  }
1024065
public static void appendSize(StringBuilder buf, long size) {
        if (size >= 104857600) { // >= 100 MiB
            buf.append(size / 1048576).append("MiB(").append(size).append("B)");
        } else if (size >= 102400) { // >= 100 KiB
            buf.append(size / 1024).append("KiB(").append(size).append("B)");
        } else {
            buf.append(size).append('B');
        }
    }
468713
public static void append(StringBuilder buf, String s, int offset, int length) {
        synchronized (buf) {
            int end = offset + length;
            for (int i = offset; i < end; i++) {
                if (i >= s.length())
                    break;
                buf.append(s.charAt(i));
            }
        }
    }
333479
public static ByteBuf wrappedBuffer(int maxNumComponents, ByteBuffer... buffers) {
        return wrappedBuffer(maxNumComponents, CompositeByteBuf.BYTE_BUFFER_WRAPPER, buffers);
    }
1038010
public static void append2digits(StringBuffer buf,int i)
    {
        if (i<100)
        {
            buf.append((char)(i/10+'0'));
            buf.append((char)(i%10+'0'));
        }
    }
205426
public static ByteBuffer minimalBufferFor(ByteBuffer buf)
    {
        return buf.capacity() > buf.remaining() || !buf.hasArray() ? ByteBuffer.wrap(getArray(buf)) : buf;
    }
304189
public int append(int newByte) {
        int old = buffer2[pos];
        buffer2[pos] = newByte;
        buffer[pos] = cs ? (char) newByte : Character.toLowerCase((char) newByte);
        pos = (++pos < buffer.length) ? pos : 0;
        return old;
    }
1206340
static void append(Appendable outputBuf, CharSequence cs) {
    try {
      outputBuf.append(cs);
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
278267
def buffer_put_lines(buf, lines):
    
    if any(isinstance(x, str) for x in lines):
        lines = [str(x) for x in lines]
    buf.write('\n'.join(lines))
20780
public static void appendElapsed(StringBuilder buf, long elapsedNanos) {
        if (elapsedNanos >= 100000000000L) { // >= 100 s
            buf.append(elapsedNanos / 1000000000L).append("s(").append(elapsedNanos).append("ns)");
        } else if (elapsedNanos >= 100000000L) { // >= 100 ms
            buf.append(elapsedNanos / 1000000L).append("ms(").append(elapsedNanos).append("ns)");
        } else if (elapsedNanos >= 100000L) { // >= 100 us
            buf.append(elapsedNanos / 1000L).append("\u00B5s(").append(elapsedNanos).append("ns)"); // microsecs
        } else {
            buf.append(elapsedNanos).append("ns");
        }
    }
685502
@Override
    public void write(char cbuf[], int off, int len) {
        buf.append(cbuf, off, len);
    }
183495
private int fillBuffer() throws IOException {
    int n = super.read(buffer, 0, BUF_SIZE);
    if (n >= 0) {
      real_pos += n;
      buf_end = n;
      buf_pos = 0;
    }
    return n;
  }
1083809
public IStringBuffer append( char[] chars, int start, int length )
    {
        if ( chars == null )
            throw new NullPointerException();
        if ( start < 0 )
            throw new IndexOutOfBoundsException();
        if ( length <= 0 )
            throw new IndexOutOfBoundsException();
        if ( start + length > chars.length ) 
            throw new IndexOutOfBoundsException();
        
        //check the necessary to resize the buffer.
        if ( count + length > buff.length ) {
            resizeTo( (count + length) * 2 + 1 );
        }
        
        for ( int j = 0; j < length; j++ ) {
            buff[count++] = chars[start+j];
        }
        
        return this;
    }
28612
@Override
  public void write(byte []buf, int offset, int length, boolean isEnd)
    throws IOException
  {
    while (length > 0) {
      if (_tail == null) {
        addBuffer(TempBuffer.create());
      }
      else if (_tail.buffer().length <= _tail.length()) {
        addBuffer(TempBuffer.create());
      }
      
      TempBuffer tail = _tail;

      int sublen = Math.min(length, tail.buffer().length - tail.length());

      System.arraycopy(buf, offset, tail.buffer(), tail.length(), sublen);

      length -= sublen;
      offset += sublen;
      _tail.length(_tail.length() + sublen);
    }
  }