I have the file allDepartments.json
in a subdirectory called fixtures
, to which I want to access from the Fixture.java
class.
This is my Fixture.java code:
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
public final class Fixture {
private static final String FIXTURES_PATH = "";
private final String fixture;
public Fixture(String fixtureName) throws IOException {
fixture = new String(Files.readAllBytes(Paths.get(FIXTURES_PATH + fixtureName)));
}
public final String getFixture() {
return fixture;
}
}
However every time he tries to access the file I get a java.nio.file.NoSuchFileException: allDepartments.json
...
I have heard of the getResource()
method and tried every combination possible of it, without success.
I need this to store multi-line strings for my JUnit tests.
What can I do?