我正在减少InputStreams
流,如下所示:
InputStream total = input.collect(
Collectors.reducing(
empty,
Item::getInputStream,
(is1, is2) -> new SequenceInputStream(is1, is2)));
对于identity InputStream
,我使用:
InputStream empty = new ByteArrayInputStream(new byte[0]);
这是可行的,但是有没有更好的方法来表示空的InputStream
发布于 2021-01-04 20:51:26
如果你的项目中有Apache commons-io
:
import org.apache.commons.io.IOUtils
IOUtils.toInputStream("")
https://stackoverflow.com/questions/49264502
复制相似问题