code: public static Operation to(File file)
     {
        return new Stream(file) {
           @Override
           public void performHttp(HttpServletRewrite event, EvaluationContext context)
           {
              final File file = new File(target.build(event, context, Transpositions.encodePath()));
              if (!file.exists())
              {
                 file.mkdirs();
                 file.delete();
                 try {
                    file.createNewFile();
                 }
                 catch (IOException e) {
                    throw new RewriteException("Could not create file for Stream operation", e);
                 }
              }
  
              Response.withOutputStreamWrappedBy(new ResponseStreamWrapper() {
  
                 @Override
                 public OutputStream wrap(HttpServletRewrite rewrite, OutputStream outputStream)
                 {
                    try {
                       BufferedOutputStream stream = new BufferedOutputStream(new FileOutputStream(file));
                       rewrite.getRequest().setAttribute(STREAM_KEY, stream);
                       log.debug("Cloning response OutputStream to file [" + file + "]");
                       return new MultiOutputStream(stream, outputStream);
                    }
                    catch (FileNotFoundException e) {
                       throw new RewriteException("Could not wrap stream", e);
                    }
                 }
  
                 @Override
                 public void finish(HttpServletRewrite rewrite)
                 {
                    try {
                       OutputStream stream = (OutputStream) rewrite.getRequest().getAttribute(STREAM_KEY);
                       if (stream != null)
                       {
                          log.debug("Closing cloned file [" + file + "] OutputStream");
                          stream.flush();
                          stream.close();
                       }
  
                    }
                    catch (Exception e) {
                       throw new RewriteException("Could not close stream", e);
                    }
                 }
              }).perform(event, context);
           }
  
           @Override
           public String toString()
           {
              return "Stream.to(\"" + target.getPattern() + "\")";
           }
        };
     }
docs: Create an {@link Operation} that duplicates content written to {@link HttpServletResponse#getOutputStream()} and
  writes it to the given {@link File}.