as in the servlet:
public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String filePath = config.getServletContext().getRealPath("/"); }
How to getRealPath in the game?
Playing is all about being easy, right? so let it be easier:
I am using Play.applicationPath , which returns File.
File
Please note that in the Play class there are some more interesting ways:
VirtualFile path = play.vfs.VirtualFile.fromRelativePath("/");
This will give you a way. Of the returned object, you can get the File object, as a String to get the path via getName()and perform usual checks the file type, for example exists(), and isDirectory()etc.
getName()
exists()
isDirectory()
Take a look at javadoc for more information.
http://www.playframework.org/documentation/api/1.1/play/vfs/VirtualFile.html
: Play.getFile(".") File
Play.getFile(".")
See javadoc: http://www.playframework.org/documentation/api/1.1/play/Play.html#getFile (java.lang.String)
In Play 2.0 (scala), try the following:
import play.api.Play.current val playPath = current.path.getAbsolutePath
The project Java Play 2.x, do the following: play.Play.application().getFile(".").
play.Play.application().getFile(".")
Source: https://habr.com/ru/post/1786045/More articles:Composite primary key update - database-designHow to use LINQ to count the number of objects in the largest group? - c #Unexpected T_STRING, waiting for T_OLD_FUNCTION or T_FUNCTION or T_VAR - phpUsing "multipart / form-data" - htmlProblem Using Paperclip and Ruby on Rails 3 - ruby | fooobar.comGraphics on the command line Mathematica 7? - wolfram-mathematicaLooking for a detailed user tracking application - javaрасчет роялти на основе диапазонов в рельсах 3 - rubyDebugging a Mathematica 5 work program with Mathematica 7 - debuggingProblems with the camera for Android - androidAll Articles