public static byte[] readBytes(InputStream inputStream) { try { FastByteArrayOutputStream byteArrayOutputStream = new FastByteArrayOutputStream(); byte[] buffer = new byte[4096]; int read; while ((read = inputStream.read(buffer)) > -1) { byteArrayOutputStream.write(buffer, 0, read); } byteArrayOutputStream.flush(); byteArrayOutputStream.close(); return byteArrayOutputStream.toByteArray(); } catch (IOException e) { throw new BaseException(e, "Failed to read from InputStream: %s", e.getMessage()); } }
public static byte[] readBytes(InputStream inputStream) { try { FastByteArrayOutputStream byteArrayOutputStream = new FastByteArrayOutputStream(); byte[] buffer = new byte[4096]; int read; while ((read = inputStream.read(buffer)) > -1) { byteArrayOutputStream.write(buffer, 0, read); } byteArrayOutputStream.flush(); byteArrayOutputStream.close(); return byteArrayOutputStream.toByteArray(); } catch (IOException e) { throw new BaseException(e, "Failed to read from InputStream: %s", e.getMessage()); } }