code: public static <T extends Writer> T pump(Reader reader, T writer, boolean closeReader, boolean closeWriter) throws IOException{
          char buff[] = new char[1024];
          int len;
          Exception exception = null;
          try{
              while((len=reader.read(buff))!=-1)
                  writer.write(buff, 0, len);
          }catch(Exception ex){
              exception = ex;
          }finally{
              try{
                  try{
                      if(closeReader)
                          reader.close();
                  }finally{
                      if(closeWriter)
                          writer.close();
                  }
              }catch(IOException ex){
                  if(exception!=null)
                      ex.printStackTrace();
                  else
                      exception = ex;
              }
          }
  
          if(exception instanceof IOException)
              throw (IOException)exception;
          else if(exception instanceof RuntimeException)
              throw (RuntimeException)exception;
  
          return writer;
      }
docs: Reads data from <code>reader</code> and writes it into <code>writer</code>.<br>
  <code>reader</code> and <code>writer</code> are closed if <code>closeReader</code> and <code>closeWriter</code>
  are true respectively.
  
  @param reader        reader from which data is read
  @param writer        writer into which data is written
  @param closeReader   close reader or not
  @param closeWriter   close writer or not
  @return              the argument <code>writer</os>
  @throws IOException if an I/O error occurs.