public static byte[] readInputStream(InputStream ins) {
if (ins == null) {
return null;
}
BufferedInputStream bis = new BufferedInputStream(ins);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
try {
byte[] buffer = new byte[128];
int n = -1;
while ((n = bis.read(buffer)) != -1) {
bos.write(buffer, 0, n);
}
} catch (IOException e) {
e.printStackTrace();
return null;
} finally {
if (bis != null) {
try {
bis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
return bos.toByteArray();
}
IO Stream Reading
最新推荐文章于 2023-12-21 17:21:19 发布