code: public static void write( Reader input,
                                Writer writer ) throws IOException {
          CheckArg.isNotNull(writer, "destination writer");
          boolean error = false;
          try {
              if (input != null) {
                  char[] buffer = new char[1024];
                  try {
                      int numRead = 0;
                      while ((numRead = input.read(buffer)) > -1) {
                          writer.write(buffer, 0, numRead);
                      }
                  } finally {
                      input.close();
                  }
              }
          } catch (IOException e) {
              error = true; // this error should be thrown, even if there is an error flushing/closing writer
              throw e;
          } catch (RuntimeException e) {
              error = true; // this error should be thrown, even if there is an error flushing/closing writer
              throw e;
          } finally {
              try {
                  writer.flush();
              } catch (IOException e) {
                  if (!error) throw e;
              } finally {
                  try {
                      writer.close();
                  } catch (IOException e) {
                      if (!error) throw e;
                  }
              }
          }
      }
docs: Write the entire contents of the supplied string to the given writer. This method always flushes and closes the writer when
  finished.
  
  @param input the content to write to the writer; may be null
  @param writer the writer to which the content is to be written
  @throws IOException
  @throws IllegalArgumentException if the writer is null