在Playframework中将资源文件作为InputStream获取 [英] Getting a resource file as an InputStream in Playframework
本文介绍了在Playframework中将资源文件作为InputStream获取的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Play.classloader.getResourceAsStream(filepath);
filepath - 相对于什么?项目根? playframework root?绝对路径?
filepath - relative to what? project root? playframework root? absolute path?
或者Play.classloader.getResourceAsStream的用法是错误的?
Or maybe the usage Play.classloader.getResourceAsStream is wrong?
推荐答案
在Play Framework中,conf目录位于类路径上,因此您可以将文件放在那里并使用getResourceAsStream打开它。
In the Play Framework the "conf" directory is on the classpath, so you can put your file there and open it with getResourceAsStream.
例如,如果你创建一个文件conf / foo.txt,你可以使用
For example if you create a file "conf/foo.txt" you can open it using
Play.classloader.getResourceAsStream("foo.txt");
这篇关于在Playframework中将资源文件作为InputStream获取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文