InputStream转byte

import java.io.ByteArrayOutputStream;

import java.io.IOException;
import java.io.InputStream;



private
byte[] toByteArray(InputStream input) throws IOException { ByteArrayOutputStream output = new ByteArrayOutputStream(); byte[] buffer = new byte[4096]; int n = 0; while (-1 != (n = input.read(buffer))) { output.write(buffer, 0, n); } return output.toByteArray(); }

 

posted @ 2021-02-04 17:02  我的博客我的人生  阅读(505)  评论(0编辑  收藏  举报