I want to list out all the file names in the public/images directory for my Scala Play Framework 2 application so that the Play Application just lists those file names to the HTML page. How can this be done?
Is there a right way to access the public/images directory to read files or list the directory? I don't want to use absolute directory paths.
There is method
getFile(relateivePath: String): File
onPlay
object and also in theApplication
class which returns file relative to application root directory. In your case:return
File
object, which representpublic/images/
directory. You can calllist
orlistFiles
on it to get contents of the directory.