A pit of the day: OutputStream to InputStream in Java

insert image description here
How to quickly convert OutputStream to InputStream?
Today, I helped my colleagues solve a pit problem of converting OutputStream to InputStream in Java. Let me record it:
don’t talk nonsense, just upload the code directly. The principle is what I think:

			ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
            byte[] bytes = outputStream.toByteArray();
            ByteBuffer buffer = ByteBuffer.wrap(bytes);
            InputStream inputStream = new ByteArrayInputStream(buffer.array());

Guess you like

Origin blog.csdn.net/qq_44918802/article/details/126524887
Recommended