package us.spotco.malwarescanner; import java.io.File; import java.util.HashSet; import java.util.Set; class Utils { private final static int MAX_FILE_SIZE = (1000 * 1000) * 50; //50MB public static Set getFilesRecursive(File root) { Set filesAll = new HashSet<>(); File[] files = root.listFiles(); if (files != null && files.length > 0) { for (File f : files) { if (f.isDirectory()) { Set filesTmp = getFilesRecursive(f); if (filesTmp != null) { filesAll.addAll(filesTmp); } } else { if (f.length() <= MAX_FILE_SIZE) {//Exclude files larger than 50MB for performance filesAll.add(f); } } } } return filesAll; } }