private File createFile(String directory, String fileName) {
    File file = new File(directory, fileName);
    try {
      if (!file.createNewFile()) {
        throw new IllegalStateException(
            "The specified file " + file.getAbsolutePath() + " already exists.");
      }
    } catch (IOException e) {
      throw new IllegalStateException(
          "IOException attempting to create file " + file.getAbsolutePath() + ".", e);
    }

    file.deleteOnExit();
    files.add(file);
    return file;
  }
Creates a new file with the given name in the specified {@link #directory}.

@param fileName the name of the file to create.

@return the file that was created.

@throws IllegalStateException if the file already exists.
@throws IllegalStateException if there is an {@link IOException} while creating the file.
geode-junit/src/main/java/org/apache/geode/test/junit/rules/TemporaryFileRule.java