Crux lp
Crux lp

Reputation: 166

Getting Resource as InputStream in Playframework

I have the following Problem in my Play-Application: I placed a file called "logfileSearch.properties" in my conf folder. Then i wanted to get a inputStream with mentioned file in it.

@Inject
Provider<Application> app;

public CustomNodeList newSearch() throws IOException {
    Application application = app.get();
    ClassLoader classLoader = application.classloader();
    InputStream inputStream = classLoader.getResourceAsStream("logfileSearch.properties");
    .....
}

With this Code i got a NullPointerException in the line:

Application application = app.get();

If someone here is able to help me i would be very happy.

More Info:

Upvotes: 0

Views: 482

Answers (1)

Sky
Sky

Reputation: 2609

you can use current class loader as described in Play documentation
like:

   this.getClass().getResourceAsStream("logfileSearch.properties");

Upvotes: 1

Related Questions