Ignasi
Ignasi

Reputation: 6185

How to get file from a dependency on Play Framework

Having a managed dependency declared on the Build.scala file, which would be the appropriate way to get a file from the dependency? (The file isn't on resources folder).

Upvotes: 2

Views: 108

Answers (1)

Ferran Maylinch
Ferran Maylinch

Reputation: 11529

https://docs.oracle.com/javase/6/docs/api/java/lang/ClassLoader.html#getResourceAsStream(java.lang.String)

Should work if the file is included in any of the sources. Check that you are specifying the fully qualified name with packages if necessary.

If your project or some jar contains a source file /some/folder/file.txt then you can access the resource using that path.

getClass().getResourceAsStream("/some/folder/file.txt");

Upvotes: 1

Related Questions