@SuppressWarnings("deprecation")
  public void writeBytes(String str) {
    if (ignoreWrites) {
      return;
    }
    checkIfWritable();
    int strlen = str.length();
    if (strlen > 0) {
      ensureCapacity(strlen);
      // I know this is a deprecated method but it is PERFECT for this impl.
      if (buffer.hasArray()) {
        // I know this is a deprecated method but it is PERFECT for this impl.
        int pos = buffer.position();
        str.getBytes(0, strlen, buffer.array(), buffer.arrayOffset() + pos);
        buffer.position(pos + strlen);
      } else {
        byte[] bytes = new byte[strlen];
        str.getBytes(0, strlen, bytes, 0);
        buffer.put(bytes);
      }
      // for (int i = 0 ; i < len ; i++) {
      // this.buffer.put((byte)s.charAt(i));
      // }
    }
  }
Writes a string to the output stream. For every character in the string <code>s</code>, taken
in order, one byte is written to the output stream. If <code>s</code> is <code>null</code>, a
<code>NullPointerException</code> is thrown.
<p>
If <code>s.length</code> is zero, then no bytes are written. Otherwise, the character
<code>s[0]</code> is written first, then <code>s[1]</code>, and so on; the last character
written is <code>s[s.length-1]</code>. For each character, one byte is written, the low-order
byte, in exactly the manner of the <code>writeByte</code> method . The high-order eight bits of
each character in the string are ignored.

@param str the string of bytes to be written.
geode-serialization/src/main/java/org/apache/geode/internal/serialization/BufferDataOutputStream.java