Java: accessing a List of Strings as an InputStream

前端 未结 7 1552
情深已故
情深已故 2021-02-05 11:24

Is there any way InputStream wrapping a list of UTF-8 String? I\'d like to do something like:

InputStream in = new XyzInputStream( List         


        
相关标签:
7条回答
  • 2021-02-05 12:04

    You can do something similar to this:

    https://commons.apache.org/sandbox/flatfile/xref/org/apache/commons/flatfile/util/ConcatenatedInputStream.html

    It just implements the read() method of InputStream and has a list of InputStreams it is concatenating. Once it reads an EOF it starts reading from the next InputStream. Just convert the Strings to ByteArrayInputStreams.

    0 讨论(0)
提交回复
热议问题