Is there any way InputStream
wrapping a list of UTF-8 String
? I\'d like to do something like:
InputStream in = new XyzInputStream( List
In my case I had to convert a list of string in the equivalent file (with a line feed for each line).
This was my solution:
List inputList = Arrays.asList("line1", "line2", "line3");
byte[] bytes = inputList.stream().collect(Collectors.joining("\n", "", "\n")).getBytes();
InputStream inputStream = new ByteArrayInputStream(bytes);