Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
EmmanuelTrejo
Contributor II
Contributor II

Count files in local

Hello everyone

I'm developing a job with a java component to get total numbers of files in a specific path.

Lines of code are:

File

carpeta

=

new

File

(

"E:\\Documentación"

);

File[] lista = carpeta.listFiles();

int

cuenta=

0

;

for

(

int

i

=

0

; i < lista.length; i++)

if

(lista[i].isFile())

cuenta++;

System.out.println(

"\n Hay "

+ cuenta +

" archivos"

);

The job is

0695b00000Riq8XAAR.png

In the code i change to read according tFileList_1 configuration

Regards.

Labels (3)
4 Replies
Anonymous
Not applicable

Hi

You don't need to hard code on tJava to get the counts of files are found in the specific path. Just use tFileList to get the file list and use the global variable.

tFileList

|onsubjob

tJava

on tJava:

int file_counts=((Integer)globalMap.get("tFileList_1_NB_FILE"));

System.out.println(file_counts);

 

Regards

Shong

EmmanuelTrejo
Contributor II
Contributor II
Author

Thanks for your help

 

The code line is exactly I need it

 

If I need to use for other path (aws) it's possible to modify that code line???

 

Regards.

 

Anonymous
Not applicable

@Emmanuel Trejo​ 

Sorry, I don't understand your question well, other path(aws)? which code line?

 

Regards

Shong

SMR040
Contributor III
Contributor III

It does not matter what the location is (local or AWS etc.), as long as you are using the tFileList you can use the Global Variables. The easiest way to do it, is to go to the Outline (bottom left in the Studio) and drag the required variable into your tJava component. In this case you would need the "Number of files - NB_FILE (Flow)".

 

0695b00000RjH9DAAV.png