code: public static <T> long drain(Source<T> source, Sink<T> sink)
              throws IOException {
          long count = 0L;
          try {
              while (source.hasNext()) {
                  count++;
                  sink.put(source.next());
              }
              return count;
          } finally {
              source.close();
          }
      }
docs: Exhausts the given source, sending each item to the given sink.
  <p>
  The source will be automatically closed regardless of success.
  
  @param source the source to exhaust.
  @param sink the sink to send each item to.
  @param <T> the type.
  @return the number of items encountered.
  @throws IOException if an I/O problem occurs.