How to use temporary folder in Junit ( with example )
The TemporaryFolder Rule allows creation of files and folders that are guaranteed to be deleted when the test method finishes (whether it passes or fails). The TemporaryFolder is a test helper belongs to one of the Junit rules.
TemporaryFolder folder= TemporaryFolder();
File createdFile= folder.newFile( );
File createdFolder= folder.newFolder( );
assertTrue( createdFolder.exists() );