1.2k questions

1.4k answers

361 comments

339 users

Categories

Sidebar
0 votes
1.9K views
by jon-t-7005 (8.2k points)

1 Answer

0 votes

The below code will read files from a directory into an array, then sort the array.

 

// Read a directory, list the files, and rearrange the array
// so the files are in ascending order by modified date
// Use LASTMODIFIED_REVERSE to reverse the order

// Get the source directory
var srcDirectory = new java.io.File("C:\\HL7\\In");

// Create a list of files in an array
var listFiles = srcDirectory.listFiles();

// Sort the array
java.util.Arrays.sort(listFiles, org.apache.commons.io.comparator.LastModifiedFileComparator.LASTMODIFIED_COMPARATOR);

// List the files in the array
for (var i = 0; i < listFiles.length; i++) {
   qie.debug(listFiles[i].getName());
}

by jon-t-7005 (8.2k points)
...