Main method writing a char into wrapped writer.

@param chr a char to be written.
@throws IOException it will be thrown for transport errors.
176542
private void writeChar(final char chr) throws IOException {
    switch (chr) {
      case '\t':
        this.Tab();
        break;
      case '\n': {
        this.out.write(this.lineSeparator);
        this.lineNumber++;
        this.prevMode = this.mode;
        this.mode = MODE_START_LINE;
        this.linePosition = 0;
        for (final Extra e : extras) {
          e.onNewLine(this, this.lineNumber);
        }
      }
      break;
      case '\r':
        break;
      default: {
        if (!Character.isISOControl(chr)) {
          this.out.write(chr);
          this.linePosition++;
          if (this.mode == MODE_START_LINE) {
            this.mode = this.prevMode;
          }
        }
      }
      break;
    }
  }
90819
private void write(int c) throws IOException {
		if (!firstCharacterWritten) {
			if (c != '\n') {
				out.write(c);
				firstCharacterWritten = true;
			}
		} else {
			out.write(c);
		}
	}
22814
public static void put(Writer writer, char value) throws IOException {
		writer.write("\"");
		writer.write(sanitize(value));
		writer.write("\"");
	}
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);
		}
	}
523849
private final int _prependOrWriteCharacterEscape(char[] buffer, int ptr, int end,
            char ch, int escCode)
        throws IOException, JsonGenerationException
    {
        if (escCode >= 0) { // \\N (2 char)
            if (ptr > 1 && ptr < end) { // fits, just prepend
                ptr -= 2;
                buffer[ptr] = '\\';
                buffer[ptr+1] = (char) escCode;
            } else { // won't fit, write
                char[] ent = _entityBuffer;
                if (ent == null) {
                    ent = _allocateEntityBuffer();
                }
                ent[1] = (char) escCode;
                _writer.write(ent, 0, 2);
            }
            return ptr;
        }
        //if (escCode != CharacterEscapes.ESCAPE_CUSTOM) { // std, \\uXXXX
            if (ptr > 5 && ptr < end) { // fits, prepend to buffer
                ptr -= 6;
                buffer[ptr++] = '\\';
                buffer[ptr++] = 'u';
                // We know it's a control char, so only the last 2 chars are non-0
                if (ch > 0xFF) { // beyond 8 bytes
                    int hi = (ch >> 8) & 0xFF;
                    buffer[ptr++] = HEX_CHARS[hi >> 4];
                    buffer[ptr++] = HEX_CHARS[hi & 0xF];
                    ch &= 0xFF;
                } else {
                    buffer[ptr++] = '0';
                    buffer[ptr++] = '0';
                }
                buffer[ptr++] = HEX_CHARS[ch >> 4];
                buffer[ptr] = HEX_CHARS[ch & 0xF];
                ptr -= 5;
            } else {
                // won't fit, flush and write
                char[] ent = _entityBuffer;
                if (ent == null) {
                    ent = _allocateEntityBuffer();
                }
                _outputHead = _outputTail;
                if (ch > 0xFF) { // beyond 8 bytes
                    int hi = (ch >> 8) & 0xFF;
                    int lo = ch & 0xFF;
                    ent[10] = HEX_CHARS[hi >> 4];
                    ent[11] = HEX_CHARS[hi & 0xF];
                    ent[12] = HEX_CHARS[lo >> 4];
                    ent[13] = HEX_CHARS[lo & 0xF];
                    _writer.write(ent, 8, 6);
                } else { // We know it's a control char, so only the last 2 chars are non-0
                    ent[6] = HEX_CHARS[ch >> 4];
                    ent[7] = HEX_CHARS[ch & 0xF];
                    _writer.write(ent, 2, 6);
                }
            }
            return ptr;
        //}
    }
529048
@Override
    public void write(String str) {
		int len = str.length();
		for (int i = 0; i < len; i++) {
			append(str.charAt(i));
		}
    }
1028539
static public void writeStringAsCharArray(Writer writer, String str) throws IOException {
        writeStringAsCharArray(writer, str, 0, str.length());
    }
156256
public void characters(char ch[], int start, int length)
    {
        if (m_CurrentString == null)
            m_CurrentString = new String(ch, start, length);
        else
            m_CurrentString += new String(ch, start, length);
    }
625750
public synchronized void write(int c) throws IOException {

        checkClosed();

        int newcount = count + 1;

        if (newcount > buf.length) {
            buf = copyOf(buf, Math.max(buf.length << 1, newcount));
        }

        buf[count] = (char) c;
        count      = newcount;
    }
1238489
public static void write(Path self, String text, String charset) throws IOException {
        Writer writer = null;
        try {
            writer = new OutputStreamWriter(Files.newOutputStream(self, CREATE, APPEND), Charset.forName(charset));
            writer.write(text);
            writer.flush();

            Writer temp = writer;
            writer = null;
            temp.close();
        } finally {
            closeWithWarning(writer);
        }
    }
1254186
public static void writeCharSequence(Writer target, CharSequence csq, int start, int end) throws IOException {
        final Class<?> csqClass = csq.getClass();
        if (csqClass == String.class) {
            target.write((String)csq, start, end - start);
        }
        else if (csqClass == StringBuffer.class) {
            char[] buf = new char[end - start];
            ((StringBuffer)csq).getChars(start, end, buf, 0);
            target.write(buf);
        }
        else if (csqClass == StringBuilder.class) {
            char[] buf = new char[end - start];
            ((StringBuilder)csq).getChars(start, end, buf, 0);
            target.write(buf);
        }
        else if (csq instanceof CharArrayAccessible) {
            char[] buf = new char[end - start];
            ((CharArrayAccessible)csq).getChars(start, end, buf, 0);
            target.write(buf);
        }
        else {
            String str = csq.subSequence(start, end).toString();
            target.write(str, 0, str.length());
        }
    }
450792
void writeString(String value) throws IOException {
        output.append('"');
        for (int i = 0; i < value.length(); i++) {
            char ch = value.charAt(i);
            if (ch < 128) {
                String replace = REPLACE[ch];
                if (replace != null) {
                    output.append(replace);
                } else {
                    output.append(ch);
                }
            } else if (ch == '\u2028') {
                output.append("\\u2028");  // match other JSON writers
            } else if (ch == '\u2029') {
                output.append("\\u2029");  // match other JSON writers
            } else {
                output.append(ch);
            }
        }
        output.append('"');
    }
137196
private void flushCharactersBuffer() throws IOException
  {
    if(charactersBuffer.position() > 0) {
      writer.write(charactersBuffer.array(), 0, charactersBuffer.position());
      charactersBuffer.rewind();
    }
  }
1233449
public void addChar(char nextCh)
    throws IOException
  {
    int ch;
    
    while ((ch = readChar()) >= 0) {
      outputChar((char) ch);
    }

    outputChar(nextCh);
  }
122122
public void write(char ... data) throws IllegalStateException, IOException{
        write(StandardCharsets.US_ASCII, CharBuffer.wrap(data));
    }
887045
void characters(CharSequence csq, int start, int end) throws IOException {
        getCurrent().characters(csq, start, end);
    }
1090178
@Override
	public void writeString(String str) throws IOException {
		byte[] bytes = Utf8.getBytesFor(str);
		writeBytes(bytes, 0, bytes.length);
	}