Example usage for org.springframework.integration.file DirectoryScanner listFiles

List of usage examples for org.springframework.integration.file DirectoryScanner listFiles

Introduction

In this page you can find the example usage for org.springframework.integration.file DirectoryScanner listFiles.

Prototype

List<File> listFiles(File directory) throws IllegalArgumentException;

Source Link

Document

Scans the directory according to the strategy particular to this implementation and returns the selected files as a File array.

Usage

From source file:com.iana.dver.pdf.scrapper.DVERScrapperTask.java

public void readAndParseDVER() throws WrongConfigurationException, IOException {
    if (scanDir == null && archiveDir == null && maxFiles == null && xmlDir == null) {
        log.info("Wrong configuration used");
        throw new WrongConfigurationException("Some configuration is missing in job");
    }/*  w  w  w . j  a v a  2 s. co m*/

    // Fetching the files up to 50
    DirectoryScanner scanner = new HeadDirectoryScanner(Integer.parseInt(maxFiles.trim()));
    File dverScanDirectory = new File(scanDir);
    if (dverScanDirectory.isDirectory()) {
        List<File> files = scanner.listFiles(dverScanDirectory);
        // Sorting the list as per created time.
        Collections.sort(files, LastModifiedFileComparator.LASTMODIFIED_COMPARATOR);
        // Iterate the files list
        for (File file : files) {
            if (file.isFile()) {
                PDFTextStripperByArea textStripper = readDVER(file);
                generateDverXML(FilenameUtils.getBaseName(file.getName()), textStripper);
            }
        }
    } else {
        throw new WrongConfigurationException("The Path to look for DVER is not a directory");
    }
}