1

私は Play Framework 2.0 を使用しています。私のテスト ケースの 1 つで、いくつかの XML/HTML ファイルの内容を読みたいと思っています。私は試してみました:

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

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

しかし、私はnullを取得します。リソースは、テスト ケースの同じパッケージにあります。ここに画像の説明を入力

4

1 に答える 1

1

多分あなたはこの方法を試すことができます:

/**
 * 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)
于 2012-04-04T07:30:23.053 に答える