You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@nifi.apache.org by sally <sa...@gmail.com> on 2017/10/30 11:36:09 UTC

Nifi:count similar filenames in directory

I want to get real name of file from one previous flowfile and then match how
many flowfile with this name exists in certain directory , here is my code
but it trows exception which tells that startup failed because unexpected
char 0XFFFF, here is my code what should i change?

*how should i connect certain hadoop directory?*
import org.apache.commons.io.IOUtils import
java.nio.charset.StandardCharsets

def flowFile=session.get();
def flowFile1=session.create();
String  filename=flowFile.getAttribute('realName').toString();
def  count1 =flowFile.getAttribute('count');\
count1=coun1t as  Number;

int count = new File("C://Users//s.tkhilaishvili//Desktop//x").listFiles()
                                  .findAll { it.name.matches(filename.*/) }
                                  .size();

if(count1== count){
flowFile1=session.putAttribute(flowFile1,"check","AllRIGHT");
}                             
flowFile1=session.putAttribute(flowFile1,"amount",count);
flowFile1=session.putAttribute(flowFile1,"filename",filename);
session.transfer(flowFile1,REL_SUCCESS);
session.remove(flowFile)



--
Sent from: http://apache-nifi-users-list.2361937.n4.nabble.com/