Marlon León
Marlon León

Reputation: 170

How to load an XML/HTML resource in Play Framework 2.0

I'm working with Play Framework 2.0. In one of my test cases I want to read the content of some XML/HTML files. I've tried with:

getClass().getResource("SomeFile.xml");

and

getClass().getResourceAsStream("SomeFile.xml");

But I get a null. The resources are in the same package of my test case.enter image description here

Upvotes: 1

Views: 1178

Answers (1)

ndeverge
ndeverge

Reputation: 21564

maybe you can try this method:

/**
 * Retrieves a resource stream from the classpath.
 *
 * @param relativePath relative path of the resource to fetch
 * @return InputStream to the resource (may be null)
 */
play.Play.application().resourceAsStream(String resourceName)

Upvotes: 1

Related Questions