bArmageddon bArmageddon - 1 month ago 18
Java Question

Getting a resource file as an InputStream in Playframework

Play.classloader.getResourceAsStream(filepath);


filepath - relative to what? project root? playframework root? absolute path?

Or maybe the usage Play.classloader.getResourceAsStream is wrong?

Answer

In the Play Framework the "conf" directory is on the classpath, so you can put your file there and open it with getResourceAsStream.

For example if you create a file "conf/foo.txt" you can open it using

Play.classloader.getResourceAsStream("foo.txt");
Comments