获得一个Writer

@param out 输入流
@param charset 字符集
@return OutputStreamWriter对象
549031
public static OutputStreamWriter getWriter(OutputStream out, Charset charset) {
		if (null == out) {
			return null;
		}

		if (null == charset) {
			return new OutputStreamWriter(out);
		} else {
			return new OutputStreamWriter(out, charset);
		}
	}
743476
public static OutputStream string2OutputStream(final String string, final String charsetName) {
        if (string == null || isSpace(charsetName)) return null;
        try {
            return bytes2OutputStream(string.getBytes(charsetName));
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return null;
        }
    }
60220
public static InternetPrintWriter createForEncoding(OutputStream outputStream, boolean autoFlush, Charset charset) {
        return new InternetPrintWriter(new OutputStreamWriter(outputStream, charset), autoFlush);
    }
993297
private void simpleWriteString(String outString, OutputStream outStream) throws IOException
   {
      for (int i = 0; i < outString.length(); i++)
      {
         int charCode = outString.charAt(i);
         outStream.write(charCode & 0xFF);
         outStream.write((charCode >> 8) & 0xFF);
      }
   }
1212667
public Writer setCharacterStream(long pos) throws SQLException {
    int bytePosition = utf8Position((int) pos - 1);
    OutputStream stream = setBinaryStream(bytePosition + 1);
    return new OutputStreamWriter(stream, StandardCharsets.UTF_8);
  }
792234
public static <T> Writer<T> writer(Format type, OutputStream out) {
        return writer(type, out, defaultDefaultWriteHandler());
    }
595364
private void writeSimpleString(OutputStream out, CharSequence value) throws IOException {
        out.write('"');
        for (int i = 0; i < value.length(); i++) {
            out.write(value.charAt(i));
        }
        out.write('"');
    }
490513
public static String read(InputStream in, Charset charset) throws IORuntimeException {
		FastByteArrayOutputStream out = read(in);
		return null == charset ? out.toString() : out.toString(charset);
	}
118535
public static void writeToOutputStream(String s, OutputStream output, String encoding) throws IOException {
		BufferedReader reader = new BufferedReader(new StringReader(s));
		PrintStream writer;
		if (encoding != null) {
			writer = new PrintStream(output, true, encoding);
		}
		else {
			writer = new PrintStream(output, true);
		}
		String line;
		while ((line = reader.readLine()) != null) {
			writer.println(line);
		}
	}
475277
public synchronized void setOutputStream(OutputStream out)
    {
        _reopen=isStarted() && out!=out;
        _filename=null;
        if (_buffer!=null)
            _buffer.resetWriter();
        _out=out;
    }
1159241
public static String outputStream2String(final OutputStream out, final String charsetName) {
        if (out == null || isSpace(charsetName)) return null;
        try {
            return new String(outputStream2Bytes(out), charsetName);
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return null;
        }
    }
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();
	}
1144598
public Writer writeTo(final Writer out) throws IOException {
        if (this.out!=null) {
            // StackOverflow prevention
            return NullWriter.DEFAULT;
        }
        try {
            this.out = createWriter(out);
            run();
            return out;
        } finally {
            if (this.out!=null) {
                this.out.flush();
            }
            this.out = null;
        }
    }
784226
public static void copy(String in, Charset charset, OutputStream out) throws IOException {
		Assert.notNull(in, "No input String specified");
		Assert.notNull(charset, "No charset specified");
		Assert.notNull(out, "No OutputStream specified");
		Writer writer = new OutputStreamWriter(out, charset);
		writer.write(in);
		writer.flush();
	}
691636
@GwtIncompatible("Writer")
  static CharOutput asCharOutput(final Writer writer) {
    checkNotNull(writer);
    return new CharOutput() {
      @Override
      public void write(char c) throws IOException {
        writer.append(c);
      }

      @Override
      public void flush() throws IOException {
        writer.flush();
      }

      @Override
      public void close() throws IOException {
        writer.close();
      }
    };
  }
556333
public void stringToOutputStream(String content, OutputStream out) throws IOException {
        out.write(content.getBytes());
        out.close();
    }
718978
public String getOutputAsString() {
		if (stringWriter != null) {
			return stringWriter.toString();
		} else if (outputStream != null) {
			String outputStr = null;

			byte[] bytes = outputStream.getOutput();
			if (bytes != null) {
				try {
					outputStr = new String(bytes, characterEncoding);
				} catch (UnsupportedEncodingException e) {
					outputStr = null;
				}
			}

			return outputStr;
		}

		return null;
	}