private void formatForOutput(String str, StringBuffer buffer, boolean key)
private void formatForOutput(String str, StringBuilder buffer, boolean key)
  private void formatForOutput(String str, StringBuffer buffer, boolean key)  {    if (key)      {        buffer.setLength(0);        buffer.ensureCapacity(str.length());      }    else      buffer.ensureCapacity(buffer.length() + str.length());    boolean head = true;    int size = str.length();    for (int i = 0; i < size; i++)      {        char c = str.charAt(i);        switch (c)          {          case '\n':            buffer.append("\\n");            break;          case '\r':            buffer.append("\\r");            break;          case '\t':            buffer.append("\\t");            break;          case ' ':            buffer.append(head ? "\\ " : " ");            break;          case '\\':          case '!':          case '#':          case '=':          case ':':            buffer.append('\\').append(c);            break;          default:            if (c < ' ' || c > '~')              {                String hex = Integer.toHexString(c);                buffer.append("\\u0000".substring(0, 6 - hex.length()));                buffer.append(hex);              }            else              buffer.append(c);          }        if (c != ' ')          head = key;      }  }