private void listFiles(File dir, List<File> results, boolean includeSubDirectories) {
        File[] found = dir.listFiles();
        if ( found != null ) {
            for ( File f : found ) {
                if (f.isDirectory()) {
                    if (includeSubDirectories) {
                        listFiles(f, results, includeSubDirectories);
                    }
                } else {
                    results.add(f);
                }
            }
        }
    }
Lists files in the directory given and adds them to the result list
passed in, optionally adding subdirectories recursively.
aws-java-sdk-s3/src/main/java/com/amazonaws/services/s3/transfer/TransferManager.java