/**
* 从输入流中获取数据
*
* @param inStream 输入流
* @return
* @throws Exception
*/
public static byte[] readStreamToByte(InputStream inStream) {
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int len = 0;
try {
while ((len = inStream.read(buffer)) != -1) {
outStream.write(buffer, 0, len);
}
} catch (IOException ex) {
log.error(ex);
} finally {
try {
inStream.close();
} catch (IOException ex) {
log.error(ex);
}
}
return outStream.toByteArray();
}
转载于:https://my.oschina.net/cshuangxi/blog/281202