Copy from a `Reader` into a `Writer`.

@param reader
A reader - the source
@param writer
a writer - the target
@param closeWriter
indicate if it shall close the writer after operation
@return the number of chars copied
487634
public static int copy(Reader reader, Writer writer, boolean closeWriter) {
        if (closeWriter) {
            return write(reader).ensureCloseSink().to(writer);
        } else {
            return write(reader).to(writer);
        }
    }
1013521
public static BufferedReader getReader(Reader reader) {
		if (null == reader) {
			return null;
		}

		return (reader instanceof BufferedReader) ? (BufferedReader) reader : new BufferedReader(reader);
	}
544806
public static void closeEL(Reader r) {
	try {
	    if (r != null) r.close();
	}
	// catch (AlwaysThrow at) {throw at;}
	catch (Throwable e) {
	    ExceptionUtil.rethrowIfNecessary(e);
	}
    }
607177
private static final void copy(Reader r, Writer w, long timeout) throws IOException {
	copy(r, w, 0xffff, timeout);
    }
502828
public static int copyAndCloseOutput(Reader input, Writer output) throws IOException {
		try {
			return copy(input, output);
		} finally {
			output.close();
		}
		
	}
264553
private static long copy(Reader input, StringBuilder output, char[] buffer)
            throws IOException {
        long bytesTransferred = 0;
        int bytesRead = 0;
        while (EOF != (bytesRead = input.read(buffer))) {
            output.append(buffer, 0, bytesRead);
            bytesTransferred += bytesRead;
        }
        return bytesTransferred;
    }
1264411
public static void pipe(Reader reader, Writer writer, int buffersize) throws IOException {
        char[] buffer = new char[buffersize];
        while (reader.read(buffer) != -1) {
            writer.write(buffer);
        }
    }
1200132
public static void write(char c, Writer writer) {
        try {
            writer.write(c);
        } catch (IOException e) {
            throw E.ioException(e);
        }
    }
1164239
public static void string2Writer(String source, Writer out) throws IOException {

		char[] buffer = source.toCharArray();
		for (int i = 0; i < buffer.length; i++) {
			out.append(buffer[i]);
		}
		out.flush();
	}
183839
public void write(Reader reader, boolean escape, boolean noBackslashEscapes) throws IOException {
    char[] buffer = new char[4096];
    int len;
    while ((len = reader.read(buffer)) >= 0) {
      byte[] data = new String(buffer, 0, len).getBytes("UTF-8");
      if (escape) {
        writeBytesEscaped(data, data.length, noBackslashEscapes);
      } else {
        write(data);
      }

    }
  }
198777
private String convertToString(Reader reader) throws IOException {
        StringBuilder stringBuilder = new StringBuilder();
        int numChars;
        char[] chars = new char[50];
        do {
            numChars = reader.read(chars, 0, chars.length);
            if (numChars > 0) {
                stringBuilder.append(chars, 0, numChars);
            }
        } while (numChars != -1);

        return stringBuilder.toString();
    }
918222
public int write( final ByteBuffer buffer) throws IOException {
		for ( Consumer< ?> consumer : consumers.values()) consumer.consume( buffer.duplicate());
		return channel.write( buffer);
	}

	/**
	 * Closes the underlying channel and completes
	 * any outstanding operations in the consumers.
	 *
	 * @throws IOException if an IO error occurs
	 */
	public void close() throws IOException {
		channel.close();
		super.close();
	}

	/**
	 * Flag indicating whether the underlying channel
	 * is open.
	 *
	 * @return true if it is open, false otherwise
	 */
	public boolean isOpen() {
		return channel.isOpen();
	}
}
734581
public Toml read(Reader reader) {
    BufferedReader bufferedReader = null;
    try {
      bufferedReader = new BufferedReader(reader);

      StringBuilder w = new StringBuilder();
      String line = bufferedReader.readLine();
      while (line != null) {
        w.append(line).append('\n');
        line = bufferedReader.readLine();
      }
      read(w.toString());
    } catch (IOException e) {
      throw new RuntimeException(e);
    } finally {
      try {
        bufferedReader.close();
      } catch (IOException e) {}
    }
    return this;
  }
679905
static public void copyStream(Reader reader, Writer writer) throws IOException {
		copyStream(reader, writer, DEFAULT_TRANSFER_BUFFER_SIZE);
	}
254756
public static long copyAndCloseOutput(InputStream input, OutputStream output) throws IOException {
		try (OutputStream outputStream = output) {
			return copy(input, outputStream);
		}
	}
1280488
public static String read(Reader reader) throws IOException {
        final char[] buffer = new char[1024];
        StringBuilder sb = new StringBuilder();
        int len;
        while ((len = reader.read(buffer)) != -1) {
            sb.append(buffer, 0, len);
        }
        return sb.toString();
    }
781029
public void parse (Reader reader) {
		try {
			char[] data = new char[1024];
			int offset = 0;
			while (true) {
				int length = reader.read(data, offset, data.length - offset);
				if (length == -1) break;
				if (length == 0) {
					char[] newData = new char[data.length * 2];
					System.arraycopy(data, 0, newData, 0, data.length);
					data = newData;
				} else
					offset += length;
			}
			parse(data, 0, offset);
		} catch (IOException ex) {
			throw new SerializationException(ex);
		} finally {
			StreamUtils.closeQuietly(reader);
		}
	}