You can use StringBuilderand add all lines to it with line breaks between them. Then create an input stream using
new ByteArrayInputStream( builder.toString().getBytes("UTF-8") );
I use UTF-8 here, but you may have to use a different encoding, depending on your data and requirements.
Also note that you may need to wrap this input stream to read the contents in turn.
, , , , .