public static String toString(Reader reader) throws IOException {
    if (reader == null) {
      return null;
    }
    try {
      StringBuilder to = new StringBuilder();
      CharBuffer charBuf = CharBuffer.allocate(BUF_SIZE);
      // must cast to super class Buffer otherwise break when running with java 11
      Buffer buf = charBuf;
      while (reader.read(charBuf) != -1) {
        buf.flip();
        to.append(charBuf);
        buf.clear();
      }
      return to.toString();
    } finally {
      ensureClosed(reader);
    }
  }
Adapted from {@code com.google.common.io.CharStreams.toString()}.
core/src/main/java/feign/Util.java