JAVA把InputStream 转 字节数组(byte[])

 

 

import org.apache.commons.io.IOUtils;

  byte[] bytes = IOUtils.toByteArray(inputStream);

 

如果没有这个包 就加下依赖

   <!-- https://mvnrepository.com/artifact/commons-io/commons-io -->
        <dependency>
            <groupId>commons-io</groupId>
            <artifactId>commons-io</artifactId>
            <version>2.4</version>
        </dependency>

 

posted @ 2021-07-22 14:28  yvioo  阅读(3831)  评论(0编辑  收藏  举报