Class disp_filetypes { public static void main(String args[]) { Path dir = \"C:\\mydir\"; List list Source Files(Path dir) throws IO Exception { List result = new Array List(); try (Directory Stream stream = Files. new Directory Stream(dir, \"*.{c,h,cpp,hppJava}\")) { for (Path entry: stream) { result. add(entry);}} catch (Directory lterator Exception ex) {//I/O error encounter during the iteration, the cause is an IO Exception throw ex .get Cause();} for(i=0;i Solution Sequential version import java.io.IOException; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; /** * * @author prmsh */ public class disp_filetypes { public static void main(String args[]) { Path dir = \"C:\\mydir\"; List<Path.listSourceFiles (Path dir) throws IOException { List<Path> result = new ArrayList<>(); long startTime = System.currentTimeMillis(); try (DirectoryStrean<Path> stream = Files.newDirectoryStream(dir, \"*.{c,h,cpp,hpp,java}\")) { for (Path entry : stream) { result.add(entry); } } catch (DirectoryIteratorException ex) { throw ex.getCause(); } for (int i = 0; i < result.size(); i++) { System.out.println(result[i]); } long endTime = System.currentTimeMillis(); long totalTime = endTime - startTime; //printing time taken System.out.println(totalTime); } } } ---------------------------------------------------------------------------------------------------------------------------------------------- Parallel version import java.io.IOException; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; /** * * @author prmsh */ public class disp_filetypes { public static void main(String args[]) { Path dir = \"C:\\mydir\"; List<Path.listSourceFiles (Path dir) throws IOException { List<Path> result = new ArrayList<>(); long startTime = System.currentTimeMillis(); try (DirectoryStrean<Path> stream = Files.newDirectoryStream(dir, \"*.{c,h,cpp,hpp,java}\")) { for (Path.parallelStream() entry : stream) { result.add(entry); } } catch (DirectoryIteratorException ex) { throw ex.getCause(); } for (int i = 0; i < result.size(); i++) { System.out.println(result[i]); } long endTime = System.currentTimeMillis(); long totalTime = endTime - startTime; //printing time taken System.out.println(totalTime); } } } .