'How to set the location of junit TemporaryFolder to an environment variable java

I'm using JUnit's TemporaryFolder class rule to create a temporary folder during JUnit run.

@Rule
public final TemporaryFolder folder = new TemporaryFolder(
        new File("C:\\usr")
);

The new folder gets created at the path like below

C:\usr\junit991415299992369999

I'm looking for new folder to be created at the root, for example:

C:\usr\

Thanks!



Sources

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

Source: Stack Overflow

Solution Source