AnsweredAssumed Answered

iterate files in directory

Question asked by on Oct 8, 2015
Latest reply on Oct 8, 2015 by

I have Blaze Advisor 7.2, and I want to process all the XML test data files in a directory, reading them into a Blaze unit test function.


The standard read_ and write methods of the BOM objects are fine for individual named files, but where we have a directory with an unknown number of files of unknown names we need something else.


I am almost there with the Blaze function below:


folder is some File initially File.newInstance("c:/testfolder/");

for each File  in folder.listFiles() do {

print ("l" it.length());

// print ("l" it.getName());


This iterates the directory, and successfully lists all the file lengths, but if I uncomment the getName() – which I need to get the filenames -  I get the build error:


Error: The '' class does not have any matching 'getName' method. There is no method with the name 'getName' that accepts 0 parameters. experiment_1.advprom /Test [experiment]/Testing/BRUnit line 38059 Blaze Advisor Compilation Problem


I have imported the class from rt.jar of the standard release of java 7.


Does anyone know what to do to get getName() to work?


(If there is a different way of reading all the files in a directory that would be a great alternative.)