private File create(File dir, String filename) throws IOException {
    File file = new File(dir, filename);
    if (file.exists()) {
      assertTrue(file.getAbsolutePath() + " already exists and could not be deleted", file.delete());
    }
    assertTrue("Segment file could not be created at path " + file.getAbsolutePath(), file.createNewFile());
    file.deleteOnExit();
    return file;
  }
A test util method to create a temporary directory.
@param dir the parent directory.
@param filename the name of the file.
@return the created temporary directory.
@throws IOException
ambry-store/src/test/java/com/github/ambry/store/BlobStoreTest.java