Write a portion of a string.

@param str String to be written
@param off Offset from which to start writing characters
@param len Number of characters to write
764247
@Override
    public void write(String str, int off, int len) {
        buf.append(str, off, off + len);
    }
110429
@Override
    public synchronized void write(final byte[] b, final int off, final int len) {
        if (off < 0 || off > b.length || len < 0 || off + len - b.length > 0) {
            throw new IndexOutOfBoundsException();
        }
        ensureCapacity(super.count + len);
        System.arraycopy(b, off, super.buf, super.count, len);
        super.count += len;
    }
530153
public void writeString(String str, String charset) throws IOException {

		if (str == null) {
			writeInt(0);
		} else {
			byte[] tmp;

			if (ByteArrayReader.encode)
				tmp = str.getBytes(charset);
			else
				tmp = str.getBytes();

			writeInt(tmp.length);
			write(tmp);
		}
	}
937142
private void writeEncoded(char[] ca,int offset, int length)
        throws IOException
    {
        if (_bout==null)
        {
            _bout = new ByteArrayOutputStream2(2*length);
            _writer = new OutputStreamWriter(_bout,StringUtil.__ISO_8859_1);
        }
        else
            _bout.reset();
        _writer.write(ca,offset,length);
        _writer.flush();
        ensureSpareCapacity(_bout.getCount());
        System.arraycopy(_bout.getBuf(),0,_buf,_size,_bout.getCount());
        _size+=_bout.getCount();
    }
770342
public void write(char cbuf[], int off, int len) {
        if ((off < 0) || (off > cbuf.length) || (len < 0) || ((off + len) > cbuf.length) || ((off + len) < 0)) {
            throw new IndexOutOfBoundsException();
        } else if (len == 0) {
            return;
        }
        buf.append(cbuf, off, len);
    }
685502
@Override
    public void write(char cbuf[], int off, int len) {
        buf.append(cbuf, off, len);
    }
136870
public ChainWriter write(char buf[], int off, int len) {
		out.write(buf, off, len);
		return this;
	}
1177438
public static final void writeUTF(OutputStream out,
                                      String str, int offset, int strlen,
                                      char[] workspace)
        throws IOException
    {
        int worklen = workspace.length;
        while (true) {
            int amt = strlen <= worklen ? strlen : worklen;
            str.getChars(offset, offset + amt, workspace, 0);
            writeUTF(out, workspace, 0, amt);
            if ((strlen -= amt) <= 0) {
                break;
            }
            offset += amt;
        }
    }
74942
public static void writeStringOpt(DataOutput out, String str) 
      throws IOException{
    if (str == null) {
      WritableUtils.writeVInt(out, NULL_STRING_LENGTH);
      return;
    }
    final int len = str.length();
    TempArrays ta = UTF8.getArrays(len);
    byte[] rawBytes = ta.byteArray;
    char[] charArray = ta.charArray;
    str.getChars(0, len, charArray, 0);

    boolean ascii = true;
    for (int i = 0; i < len; i++) {
      if (charArray[i] > UTF8.MAX_ASCII_CODE) {
        ascii = false;
        break;
      }
      rawBytes[i] = (byte) charArray[i];
    }
    if(ascii) {
      WritableUtils.writeVInt(out, len);
      out.write(rawBytes, 0, len);
    } else {
      writeString(out, str);
    }
  }
748573
public static void writeUTF(@NotNull final OutputStream stream, @NotNull final String str) throws IOException {
        try (DataOutputStream dataStream = new DataOutputStream(stream)) {
            int len = str.length();
            if (len < SINGLE_UTF_CHUNK_SIZE) {
                dataStream.writeUTF(str);
            } else {
                int startIndex = 0;
                int endIndex;
                do {
                    endIndex = startIndex + SINGLE_UTF_CHUNK_SIZE;
                    if (endIndex > len) {
                        endIndex = len;
                    }
                    dataStream.writeUTF(str.substring(startIndex, endIndex));
                    startIndex += SINGLE_UTF_CHUNK_SIZE;
                } while (endIndex < len);
            }
        }
    }
483939
public void write(final byte[] src, int off, int len)
	{
		if(src == null) throw new NullPointerException();
		if((off < 0) || (off > src.length) || (len < 0) || ((off + len) > src.length) || ((off + len) < 0)) throw new IndexOutOfBoundsException();

		writeLoop(src, off, len);		
	}
130340
def write(str)
      s = str.to_s
      @length += Rack::Utils.bytesize(s)
      @writer.call s

      header["Content-Length"] = @length.to_s
      str
    end
103225
public static void writeStringAsText(DataOutput stream, String str) throws IOException {
    byte[] utf8Encoded = str.getBytes(StandardCharsets.UTF_8);
    writeVLong(stream, utf8Encoded.length);
    stream.write(utf8Encoded);
  }
1086526
public void write(byte[] b, int off, int len) throws IOException {
	if (b != null) {
	    if (off + len > b.length) {
		len = b.length - off;
	    }
	    if (len <= 0) {
		return;
	    }
	    pos += blob.write(b, off, pos, len);
	}
    }
582107
def write_str(str)
      loop do
        len = str.length

        if @chars + len < chars_per_line
          $pause_output_out.write(str)
          @chars += len
          return
        else
          tipping_point = chars_per_line - @chars
          $pause_output_out.write(str[0, tipping_point])
          count_lines

          str = (str[tipping_point..-1])
        end
      end
    end
620489
public void write(String str, boolean escape, boolean noBackslashEscapes) throws IOException {

    int charsLength = str.length();

    //not enough space remaining
    if (charsLength * 3 + 2 >= buf.length - pos) {
      byte[] arr = str.getBytes("UTF-8");
      if (escape) {
        write(QUOTE);
        writeBytesEscaped(arr, arr.length, noBackslashEscapes);
        write(QUOTE);
      } else {
        write(arr, 0, arr.length);
      }
      return;
    }

    //create UTF-8 byte array
    //since java char are internally using UTF-16 using surrogate's pattern, 4 bytes unicode characters will
    //represent 2 characters : example "\uD83C\uDFA4" = 🎤 unicode 8 "no microphones"
    //so max size is 3 * charLength
    //(escape characters are 1 byte encoded, so length might only be 2 when escape)
    // + 2 for the quotes for text protocol
    int charsOffset = 0;
    char currChar;

    //quick loop if only ASCII chars for faster escape
    if (escape) {
      buf[pos++] = QUOTE;
      if (noBackslashEscapes) {
        for (; charsOffset < charsLength && (currChar = str.charAt(charsOffset)) < 0x80;
            charsOffset++) {
          if (currChar == QUOTE) {
            buf[pos++] = QUOTE;
          }
          buf[pos++] = (byte) currChar;
        }
      } else {
        for (; charsOffset < charsLength && (currChar = str.charAt(charsOffset)) < 0x80;
            charsOffset++) {
          if (currChar == BACKSLASH || currChar == QUOTE || currChar == 0
              || currChar == DBL_QUOTE) {
            buf[pos++] = BACKSLASH;
          }
          buf[pos++] = (byte) currChar;
        }
      }
    } else {
      for (; charsOffset < charsLength && (currChar = str.charAt(charsOffset)) < 0x80;
          charsOffset++) {
        buf[pos++] = (byte) currChar;
      }
    }

    //if quick loop not finished
    while (charsOffset < charsLength) {
      currChar = str.charAt(charsOffset++);
      if (currChar < 0x80) {
        if (escape) {
          if (noBackslashEscapes) {
            if (currChar == QUOTE) {
              buf[pos++] = QUOTE;
            }
          } else if (currChar == BACKSLASH || currChar == QUOTE || currChar == ZERO_BYTE
              || currChar == DBL_QUOTE) {
            buf[pos++] = BACKSLASH;
          }
        }
        buf[pos++] = (byte) currChar;
      } else if (currChar < 0x800) {
        buf[pos++] = (byte) (0xc0 | (currChar >> 6));
        buf[pos++] = (byte) (0x80 | (currChar & 0x3f));
      } else if (currChar >= 0xD800 && currChar < 0xE000) {
        //reserved for surrogate - see https://en.wikipedia.org/wiki/UTF-16
        if (currChar < 0xDC00) {
          //is high surrogate
          if (charsOffset + 1 > charsLength) {
            buf[pos++] = (byte) 0x63;
          } else {
            char nextChar = str.charAt(charsOffset);
            if (nextChar >= 0xDC00 && nextChar < 0xE000) {
              //is low surrogate
              int surrogatePairs =
                  ((currChar << 10) + nextChar) + (0x010000 - (0xD800 << 10) - 0xDC00);
              buf[pos++] = (byte) (0xf0 | ((surrogatePairs >> 18)));
              buf[pos++] = (byte) (0x80 | ((surrogatePairs >> 12) & 0x3f));
              buf[pos++] = (byte) (0x80 | ((surrogatePairs >> 6) & 0x3f));
              buf[pos++] = (byte) (0x80 | (surrogatePairs & 0x3f));
              charsOffset++;
            } else {
              //must have low surrogate
              buf[pos++] = (byte) 0x3f;
            }
          }
        } else {
          //low surrogate without high surrogate before
          buf[pos++] = (byte) 0x3f;
        }
      } else {
        buf[pos++] = (byte) (0xe0 | ((currChar >> 12)));
        buf[pos++] = (byte) (0x80 | ((currChar >> 6) & 0x3f));
        buf[pos++] = (byte) (0x80 | (currChar & 0x3f));
      }
    }
    if (escape) {
      buf[pos++] = QUOTE;
    }

  }
1186118
public void append(String str, int off, int len) throws IOException {
	append(str.substring(off, off + len));
    }