code: static public byte[] getBytes(StringBuffer data) {
          if (null == data) {
              return null;
          }
          int len = data.length();
          char[] chars = new char[len];
          data.getChars(0, len, chars, 0);
          byte[] bytes = new byte[len];
          for (int i = 0; i < len; i++) {
              bytes[i] = (byte) chars[i];
          }
          return bytes;
      }
docs: Utility method to get the bytes from a StringBuffer. These bytes will
  be in whatever encoding was in the original chars put into the string
  buffer object.
  
  @param data
  @return byte[]