以便平常使用
public static byte[] read(InputStream inputStream) throws IOException {
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
byte[] buffer = new byte[1024];
int num = 0;
while ((num = inputStream.read(buffer)) != -1) {
baos.write(buffer, 0, num);
}
baos.flush();
return baos.toByteArray();
}
finally {
if (inputStream != null) {
inputStream.close();
}
}
}