'Is there an analogue to getResources, but using a path outside the project defined as an environment variable?

I know that if I want to get a resource for use in my unit tests, I can do something like:

String configPath = Objects.requireNonNull(
    TestResources.class
        .getClassLoader()
        .getResource("config.properties")).getPath();

We also have some resources that are in a path defined in an environment variable. For that case we have been doing something like:

String testDataPath = env.get("TEST_DATA")
String specificUseCase = Paths.get(testDataPath, "path", "to", "specific", "resource").toString();

In this case, I'm using a relative path from TEST_DATA. Is there a way to cut relative paths out of the picture completely?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source