/**
* 读取输入流数据
* //此方法是用于缓存H5网络请求数据,解决inputStream对象不能重复复用的问题
*/
public static byte[] streamToData(InputStream uristream) {
ByteArrayOutputStream outStream = null;
try {
outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = uristream.read(buffer)) != -1) {
outStream.write(buffer, 0, len);
}
return outStream.toByteArray();
} catch (Exception e) {
return null;
} finally {
try {
if(uristream !=null) {
uristream.close();
}
if (outStream != null) {
outStream.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
byte[] data = FileUtils.streamToData(inputstream);//把需要复用的inputStream保存为data
InputStream in1 = new ByteArrayInputStream(data)
InputStream in2 = new ByteArrayInputStream(data)