code: public static byte[] getBytes(InputStream in) {
          ByteArrayOutputStream os = new ByteArrayOutputStream();
          WritableByteChannel wbc = Channels.newChannel(os);
          ReadableByteChannel rbc = Channels.newChannel(in);
          ByteBuffer byteBuffer = ByteBuffer.allocate(1024);
          try {
              while (rbc.read(byteBuffer) != -1) {
                  byteBuffer.flip();
                  wbc.write(byteBuffer);
                  byteBuffer.clear();
              }
              wbc.close();
              rbc.close();
              return os.toByteArray();
          } catch (IOException e) {
              throw new HerokuAPIException("IOException while reading response", e);
          }
      }
docs: Converts an {@link InputStream} to a byte array
  @param in input stream to convert
  @return byte array