public static byte[] streamToBytes(InputStream input) {
ByteArrayOutputStream output = new ByteArrayOutputStream();
byte[] buffer = new byte[4096];
int n = 0;
try {
while (-1 != (n = input.read(buffer))) {
output.write(buffer, 0, n);
}
} catch (IOException e) {
e.printStackTrace();
}
return output.toByteArray();
}


![android InputStream 转byte[] android InputStream 转byte[]](http://www.mshxw.com/aiimages/31/301818.png)
