List of Files in any Folder - Scala
If you are allowed to, I would strongly suggest using https://github.com/pathikrit/better-files to do this. The code would look like :

import better.files._
class GetFileCount {
  def getFilesCount(dir: String):Int = {
    File(dir).glob("**").count(_.isRegularFile)        
  }
}


If you can't or won't use better-files, you can probably improve your code using just nio:

import java.nio.file.{ FileSystems, Paths, Path, Files }
import java.util.function.Predicate
import java.util.stream.Stream
object GetFileCount{
  val regularFilePredicate = new Predicate[Path] {
    override def test(path: Path) = Files.isRegularFile(path)
  }
}
class GetFileCount {
  import GetFileCount._
  def getFilesCount(dir: String): Int = {
    val path: Path = FileSystems.getDefault.getPath("/tmp/d1")
    val filter: Stream[Path] = Files.walk(path).filter(regularFilePredicate)
    filter.toArray.length
  }
}