I have the following file
/app/menus/menu1.yml
and I'd like to read it's contents
--
short answer:
fileContent = play.vfs.VirtualFile.fromRelativePath("/app/menus/menu1.yml").contentAsString();
Play comes with two configurable server backends, which handle the low level work of processing HTTP requests and responses to and from TCP/IP packets. Starting in 2.6. x, the default server backend is the Akka HTTP server backend, based on the Akka-HTTP server. Prior to 2.6.
Play Framework is the best full-stack web framework available in the current market to develop Reactive Web Applications, Reactive systems, Reactive architecture, Reactive microservices, or Reactive libraries using both FP and RP paradigms, that is, FRP.
Play has been updated to use Activator so that we can: Extend the range of templates we provide for getting started with Play projects. Activator supports a much richer library of project templates. Templates can also include tutorials and other resources for getting started.
Internally, Play Framework is asynchronous from the bottom up. Play handles every request in an asynchronous, non-blocking way. The default configuration is tuned for asynchronous controllers.
PlayFramework is built using the Java language.
In your code, there is no restriction about the usage of the java API. So, your file can be read using the standard java code, if you know the file absolute path:
java.io.File yourFile = new java.io.File("/path/app/menus/menu1.yml");
java.io.FileReader fr = new java.io.FileReader(yourFile);
// etc.
If you want to access a File in a relative path from your Play application, your can use the play "VirtualFile" class: http://www.playframework.org/documentation/api/1.1/play/vfs/VirtualFile.html
VirtualFile vf = VirtualFile.fromRelativePath("/app/menus/menu1.yml");
File realFile = vf.getRealFile();
FileReader fr = new FileReader(realFile);
// etc.
For Play 2.0 in Scala you want to use Play.getFile(relativePath: String)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With