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