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>