How can I get a java.io.InputStream from a java.lang.String?

前端 未结 8 876
悲&欢浪女
悲&欢浪女 2020-12-23 20:23

I have a String that I want to use as an InputStream. In Java 1.0, you could use java.io.StringBufferInputStream, but that has been @Deprecra

8条回答
  •  情书的邮戳
    2020-12-23 20:42

    A solution is to roll your own, creating an InputStream implementation that likely would use java.nio.charset.CharsetEncoder to encode each char or chunk of chars to an array of bytes for the InputStream as necessary.

提交回复
热议问题