Like puts but writes to a CharBuf.

@param buf      char buf
@param messages messages to write.
@return string created.
329692
public static CharBuf sputs(CharBuf buf, Object... messages) {
        int index = 0;
        for (Object message : messages) {
            if (index != 0) {
                buf.add(' ');
            }
            index++;
            if (message == null) {
                buf.add("<NULL>");
            } else if (message instanceof char[]) {
                buf.add(((char[]) message));
            } else if (message.getClass().isArray()) {
                buf.add(toListOrSingletonList(message).toString());
            } else {
                buf.add(message.toString());
            }
        }
        buf.add('\n');
        return buf;
    }

    public static StringBuilder sputs(StringBuilder buf, Object... messages) {

        int index = 0;
        for (Object message : messages) {
            if (index != 0) {
                buf.append(' ');
            }
            index++;

            if (message == null) {
                buf.append("<NULL>");
            } else if (message.getClass().isArray()) {
                buf.append(toListOrSingletonList(message).toString());
            } else {
                buf.append(message.toString());
            }
        }
        buf.append('\n');

        return buf;

    }

    public static String toPrettyJson(Object object) {

        CharBuf buf = CharBuf.createCharBuf();
        return buf.prettyPrintObject(object, false, 0).toString();
    }

    public static String toPrettyJsonWithTypes(Object object) {

        CharBuf buf = CharBuf.createCharBuf();
        return buf.prettyPrintObject(object, true, 0).toString();
    }
}
1311645
@Override
  public void write(byte []buf, int offset, int length, boolean isEnd)
    throws IOException
  {
    int end = offset + length;
    while (offset < end) {
      int ch1 = buf[offset++] & 0xff;

      if (ch1 < 0x80)
        _cb.append((char) ch1);
      else if ((ch1 & 0xe0) == 0xc0) {
        if (offset >= end)
          throw new EOFException("unexpected end of file in utf8 character");
        
        int ch2 = buf[offset++] & 0xff;
        if ((ch2 & 0xc0) != 0x80)
          throw new CharConversionException("illegal utf8 encoding");
      
        _cb.append((char) (((ch1 & 0x1f) << 6) + (ch2 & 0x3f)));
      }
      else if ((ch1 & 0xf0) == 0xe0) {
        if (offset + 1 >= end)
          throw new EOFException("unexpected end of file in utf8 character");
        
        int ch2 = buf[offset++] & 0xff;
        int ch3 = buf[offset++] & 0xff;
      
        if ((ch2 & 0xc0) != 0x80)
          throw new CharConversionException("illegal utf8 encoding");
      
        if ((ch3 & 0xc0) != 0x80)
          throw new CharConversionException("illegal utf8 encoding");
      
        _cb.append((char) (((ch1 & 0x1f) << 12) + ((ch2 & 0x3f) << 6) + (ch3 & 0x3f)));
      }
      else
        throw new CharConversionException("illegal utf8 encoding at (" +
                                          (int) ch1 + ")");
    }
  }
804579
@Override
  public StringBuilder appendToBuffer(StringBuilder buf) {
    buf.append(super.getTask());
    if (isComplete()) {
      buf.append(": complete.");
    } else {
      buf.append(" #").append(getProcessed()+1).append('/').append(getTotal());
      buf.append(": ").append(getStepTitle());
    }
    buf.append('\n');
    return buf;
  }
375064
public ISynchronizationPoint<IOException> write(CharBuffer[] chars) {
		ISynchronizationPoint<IOException> last = lastWrite;
		for (int i = 0; i < chars.length; ++i)
			last = write(chars[i]);
		return last;
	}
998325
@Override
  public void encode(ByteBuf buf) {
    Encoders.Strings.encode(buf, streamId);
    buf.writeLong(byteCount);
  }
472805
public void write(byte []buf, int offset, int length, boolean isEnd)
    throws IOException
  {
    OutputStream os = _os;
    
    if (os != null) {
      os.write(buf, offset, length);
    }
  }
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);
        }
    }
175145
public ISynchronizationPoint<IOException> write(CharBuffer chars) {
		return write(chars.array(), chars.position(), chars.remaining());
	}
575624
@Override
  public StringBuilder appendToBuffer(StringBuilder buf) {
    buf.append(getTask());
    buf.append(": ");
    buf.append(getProcessed());
    return buf;
  }
935747
protected void writeOut(byte[] buf, int offset, int len) throws IOException
	{
		if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&logger.isLoggable (Level.FINE)) {  //306998.15
			logger.logp(Level.FINE, CLASS_NAME,"writeOut", "writeOut len --> "+len);
        }
		out.write(buf, offset, len);
	}
500630
public void write(ByteArrayBuffer buf) {
        data.copy(buf.data, 0, pointer, buf.length());
        pointer += buf.length();
    }
1081121
private static String flush(StringBuilder buf) {
    final String s = buf.toString();
    buf.setLength(0);
    return s;
  }
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;
    }
1311993
public static void writeString(String value, ByteBuffer buf) {
        if (value == null) {
            buf.putInt(VoltType.NULL_STRING_LENGTH);
            return;
        }

        byte[] strbytes = value.getBytes(Constants.UTF8ENCODING);
        int len = strbytes.length;

        buf.putInt(len);
        buf.put(strbytes);
    }
432503
public StrBuilder append(final char[] chars) {
        if (chars == null) {
            return appendNull();
        }
        final int strLen = chars.length;
        if (strLen > 0) {
            final int len = length();
            ensureCapacity(len + strLen);
            System.arraycopy(chars, 0, buffer, len, strLen);
            size += strLen;
        }
        return this;
    }
755544
public static String sputs(Object... messages) {
        CharBuf buf = CharBuf.create(80);
        return sputs(buf, messages).toString();
    }
448510
public Promise<Void> write(ByteBuf buf) {
		return sanitize(ofBlockingRunnable(executor, () -> {
			synchronized (mutexLock) {
				try {
					int writtenBytes;
					do {
						ByteBuffer byteBuffer = buf.toReadByteBuffer();
						writtenBytes = channel.write(byteBuffer);
						buf.ofReadByteBuffer(byteBuffer);
					} while (writtenBytes != -1 && buf.canRead());
				} catch (IOException e) {
					throw new UncheckedException(e);
				} finally {
					buf.recycle();
				}
			}
		}));
	}