code: private static long copy(Reader input, StringBuilder output, char[] buffer)
              throws IOException {
          long bytesTransferred = 0;
          int bytesRead = 0;
          while (EOF != (bytesRead = input.read(buffer))) {
              output.append(buffer, 0, bytesRead);
              bytesTransferred += bytesRead;
          }
          return bytesTransferred;
      }
docs: Transfers data from Reader into StringBuilder
  
  @param input  Reader which would be read
  @param output StringBuilder which would be filled
  @param buffer buffer which is used for read/write operations
  @return amount of bytes transferred
  @throws IOException