private List<File> findDuplicateFiles(List<File> files){
  HashSet<File> sourceFileSet=new HashSet<>();
  List<File> duplicateFiles=new ArrayList<>();
  for (  File file : files) {
    if (!sourceFileSet.contains(file)) {
      sourceFileSet.add(file);
    }
 else {
      duplicateFiles.add(file);
    }
  }
  return duplicateFiles;
}

private List < File > findDuplicateFiles ( List < File > files ) { HashSet < File > sourceFileSet = new HashSet < > ( ) ; List < File > duplicateFiles = new ArrayList < > ( ) ; for ( File file : files ) { if ( ! sourceFileSet . contains ( file ) ) { sourceFileSet . add ( file ) ; } else { duplicateFiles . add ( file ) ; } } return duplicateFiles ; }
returns a list of all duplicate files found in the specified list of files .
