I need to use a class whose constructor takes an InputStream as an
argument. The class uses this InputStream elsewhere to read in data.
I want to provide this data to an instance of this class in the form
of a String (or StringBuffer). The recommended way to read from a
String is to use an instance of the StringReader class, but I have not
been able to find a wrapper class for StringReader to produce an
InputStream. Isn't there a standard way to do this in Java?
Thanks,
bill
P.S. I *did* consult http://mindprod.com/FileIO.html, but it was no
help with this problem. All it told me was to use StringReader, which
I already knew.
Don't use StringReader. Use ByteArrayInputStream instead. Just use
getBytes(encoding) to convert the String to a byte array, and then use the
byte array as the argument for the ByteArrayInputStream.