[英]Getting Resource as InputStream in Playframework
我的播放应用程序中存在以下问题:我在conf文件夹中放置了一个名为“ logfileSearch.properties”的文件。 然后我想获得一个带有提及文件的inputStream。
@Inject
Provider<Application> app;
public CustomNodeList newSearch() throws IOException {
Application application = app.get();
ClassLoader classLoader = application.classloader();
InputStream inputStream = classLoader.getResourceAsStream("logfileSearch.properties");
.....
}
有了这段代码,我在行中得到了NullPointerException:
Application application = app.get();
如果有人可以帮助我,我将非常高兴。
更多信息:
您可以按照Play文档中的说明使用当前的类加载器
喜欢:
this.getClass().getResourceAsStream("logfileSearch.properties");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.