将 StreamingOutput 转换为 InputStream

问题描述 投票:0回答:0

我正在开发一个程序来转换 StreamingOutput,我需要转换为 InputStream 以保存在 myFilSytem 中。 我尝试遵循代码,但它无法正确转换。

InputStream convertToInputStream(StreamingOutput output) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
        try {
            output.write(outputStream);
        } catch (IOException e) {
            throw new WebApplicationException("Error writing to output stream", e);
        }
return new ByteArrayInputStream(outputStream.toByteArray());
}

does this needs any correction or do we have any better way for converting

Streamingoutput 包含文档,需要转换为 inputStream 才能发送给其他微服务。

java streaming inputstream fileinputstream fileoutputstream
© www.soinside.com 2019 - 2024. All rights reserved.