流转化为字节数组输出流
//转化流类型为字节数组输入流
private ByteArrayInputStream socketToByteByStream(InputStream inputStream) {
ByteArrayInputStream byteArrayInputStream = null;
try {
BufferedInputStream bufferedInputStream = new BufferedInputStream(inputStream);
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
byte[] buffer = null;
int len = 0;
byte[] buf = new byte[2048];
while ((len = bufferedInputStream.read(buf)) != -1) {
byteArrayOutputStream.write(buf, 0, len);
}
byteArrayOutputStream.flush();
buffer = byteArrayOutputStream.toByteArray();
byteArrayInputStream = new ByteArrayInputStream(buffer);
} catch (IOException e) {
e.printStackTrace();
}
return byteArrayInputStream;
}