Java – How to turn a String into a InputStreamReader in java

javastreamstring

How can I transform a String value into an InputStreamReader?

Best Solution

ByteArrayInputStream also does the trick:

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

Then convert to reader:

InputStreamReader reader = new InputStreamReader(is);