Working with file systems is a vital part of many Java applications, and counting files recursively in a directory tree…