private void addFileToWatchedList(File file) { filesToWatch.add(file); Map<File, FileInfo> map = new HashMap<>(); if (file.isDirectory()) { // We're watching a directory contents and its children for changes File[] children = file.listFiles(); if (children != null) { for (File child : children) { map.put(child, new FileInfo(child.lastModified(), child.length())); if (child.isDirectory()) { addFileToWatchedList(child); } } } } else { // Not a directory - we're watching a specific file - e.g. a jar map.put(file, new FileInfo(file.lastModified(), file.length())); } fileMap.put(file, map); }
private void addFileToWatchedList(File file) { filesToWatch.add(file); Map<File, FileInfo> map = new HashMap<>(); if (file.isDirectory()) { // We're watching a directory contents and its children for changes File[] children = file.listFiles(); if (children != null) { for (File child : children) { map.put(child, new FileInfo(child.lastModified(), child.length())); if (child.isDirectory()) { addFileToWatchedList(child); } } } } else { // Not a directory - we're watching a specific file - e.g. a jar map.put(file, new FileInfo(file.lastModified(), file.length())); } fileMap.put(file, map); }