title: Nifi: how to transfer only last file from the flowFile list?
body: <p>I want to get all  flowfile from the  queu   which  fileSize  is greater  than 831  and then put  them  into  the  list  after that   catch  last flowfile from the  list  and  transfer to  success relationship  and finally  remove all other  flowfiles  ,  here is  my  code   which throws  exception that <strong>transfer relationship not specified</strong> , what  should  i  change  in this case?</p>
  
  <pre><code> import org.apache.nifi.processor.FlowFileFilter;
  import groovy.json.JsonSlurper
  import groovy.json.JsonBuilder
  import java.nio.charset.StandardCharsets
  import org.apache.commons.io.IOUtils
  
  def flowFile = session.get()
  def  n=0;
  if(!flowFile)return
  def size = flowFile.getAttribute('fileSize');
  log.error(size.toString())
  int value = size as Integer;
  
  if((value/831)&gt;1){
  def ffList = session.get(new FlowFileFilter(){
      public FlowFileFilterResult filter(FlowFile ff) {
  
          if( size == ff.getAttribute('fileSize') ) n++; return FlowFileFilterResult.ACCEPT_AND_CONTINUE
          return FlowFileFilterResult.REJECT_AND_CONTINUE
      }
  
  })
  session.transfer(ffList.get(n-1),REL_SUCCESS)
  //session.remove(ffList);
  }
  session.remove(flowFile);
  </code></pre>