"FSS tests base" provides a junit test case that provides a empty, temporary, directory before your test starts, and removes it safely after it is done. Use it by creating a JUnit4 test class that extends TmpdirEnabledTestCase.