code: public static byte[] copyToByteArray(InputStream in) throws IOException {
          ByteArrayOutputStream out = new ByteArrayOutputStream(BUFFER_SIZE);
          copy(in, out);
          return out.toByteArray();
      }
docs: Copy the contents of the given InputStream into a new byte array.
  Closes the stream when done.
  
  @param in the stream to copy from
  @return the new byte array that has been copied to
  @throws IOException in case of I/O errors