Hi,
I have a requirement where I need to get the file count from the path using
the groovy script.
I came up with the below but unable to filter and count only txt files .
Any suggestions please?
import org.apache.commons.io.IOUtils
import java.nio.charset.*;
import java.io.*;
def flowFile = session.get()
if(!flowFile) return
def eahpath = flowFile.getAttribute("eahpath")
*def count = new File(eahpath).listFiles().size(); // I need to filter
only txt files and get count*
flowFile=session.putAttribute(flowFile,"eahfilecount",count+"");
def fail = false
if(fail){
session.transfer(flowFile, REL_FAILURE)
fail = false
} else {
session.transfer(flowFile, REL_SUCCESS)
}
Thanks,
Asmath