How to convert a Reader to InputStream and a Writer to OutputStream?

前端 未结 12 2073
慢半拍i
慢半拍i 2020-12-02 07:31

Is there an easy way to avoid dealing with text encoding problems?

12条回答
  •  無奈伤痛
    2020-12-02 08:14

    You can use Cactoos (no static methods, only objects):

    • new InputStreamOf(reader)
    • new OutputStreamTo(writer)

    You can convert the other way around too:

    • new ReaderOf(inputStream)
    • new WriterTo(outputStream)

提交回复
热议问题