最简单的方法是创建一个new
ByteArrayOutputStream,将字节复制到其中,然后调用
toByteArray:
public static byte[] readFully(InputStream input) throws IOException{ byte[] buffer = new byte[8192]; int bytesRead; ByteArrayOutputStream output = new ByteArrayOutputStream(); while ((bytesRead = input.read(buffer)) != -1) { output.write(buffer, 0, bytesRead); } return output.toByteArray();}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)