Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get File using relative path play framework 2.2 java

I'm trying the following to create a File:

java.io.File myFile = play.Application.getFile("/public/myFiles/myFile.txt");

which is causing the error:

non-static method getFile(java.lang.String) cannot be referenced from a static context

how do use the getFile method to return what I want?

like image 742
user2179977 Avatar asked Oct 17 '13 17:10

user2179977


1 Answers

getFile isn't a static method so you need to reference it from an instance of Application.

This should work to get you the current Application instance:

Play.application().getFile(...)
like image 198
estmatic Avatar answered Sep 28 '22 14:09

estmatic