Java 缺少来自RelativePath的playframework 2.0虚拟文件

Java 缺少来自RelativePath的playframework 2.0虚拟文件,java,playframework,playframework-2.0,Java,Playframework,Playframework 2.0,在Play1.x中,可以使用代码从相对应用程序的路径获取文件。像这样: static File xmlDataFile= VirtualFile.fromRelativePath( "/app/parsers/data/some_data.xml" ).getRealFile(); 此代码不是控制器的代码。但是应用程序/解析器包中的一些代码 如何在PlayFramework2.x中实现这一点?为了Java 见此: public static Result men

在Play1.x中,可以使用代码从相对应用程序的路径获取文件。像这样:

static File xmlDataFile= VirtualFile.fromRelativePath(
            "/app/parsers/data/some_data.xml"
    ).getRealFile();
此代码不是控制器的代码。但是应用程序/解析器包中的一些代码

如何在PlayFramework2.x中实现这一点?为了Java

见此:
public static Result menu() throws IOException {

    String path = Play.application().resource("/resources/menu.json").toString();

    String content = Files.toString(new File(path), Charsets.UTF_8);

    return ok(content).as("JSON");
}