/** * Reads the contents of an input stream and returns a byte array. * * @param inputStream the input to read from. * @return A byte array whose length is equal to the number of bytes contained. */ static byte[] _readFully(InputStream inputStream, UnsynchronizedBuffer buffer) throws IOException { final byte[] bytes = PER_THREAD_BUFFER.get(); for (;;) { int count = inputStream.read(bytes, 0, bytes.length); if (count < 0) { break; } buffer.write(bytes, 0, count); } return buffer.toArray(); }
/** * Reads the contents of an input stream and returns a byte array. * * @param inputStream the input to read from. * @return A byte array whose length is equal to the number of bytes contained. */ static byte[] _readFully(InputStream inputStream, UnsynchronizedBuffer buffer) throws IOException { final byte[] bytes = PER_THREAD_BUFFER.get(); for (;;) { int count = inputStream.read(bytes, 0, bytes.length); if (count < 0) { break; } buffer.write(bytes, 0, count); } return buffer.toArray(); }