public static byte[] readInputStream(InputStream inStream) throws Exception {
try {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
while ((len = inStream.read(buffer)) != -1) {
outStream.write(buffer, 0, len);
}
inStream.close();
return outStream.toByteArray();
}catch (Exception e){
e.printStackTrace();
throw new Exception(e);
}
}
网上都是这种处理方式 写死有越界的可能性
不知道有没有其他的处理方式