How do I turn a String into a InputStreamReader in java?

如何将String值转换为InputStreamReader


ByteArrayInputStream也有诀窍:

InputStream is = new ByteArrayInputStream( myString.getBytes( charset ) );

我也发现了apache的commons IOUtils类,所以:

InputStreamReader isr = new InputStreamReader(IOUtils.toInputStream(myString));

Does it have to be specifically an InputStreamReader? How about using StringReader?

Otherwise, you could use StringBufferInputStream, but it's deprecated because of character conversion issues (which is why you should prefer StringReader).

链接地址: http://www.djcxy.com/p/13750.html

上一篇: 如何将Reader转换为InputStream并将Writer转换为OutputStream?

下一篇: 如何在Java中将字符串转换为InputStreamReader?