code: public static File createTempFile(String prefix, String suffix, File directory)
              throws IOException {
          // Force a prefix null check first
          if (prefix.length() < 3) {
              throw new IllegalArgumentException("prefix must be at least 3 characters");
          }
          if (suffix == null) {
              suffix = ".tmp";
          }
          File tmpDirFile = directory;
          if (tmpDirFile == null) {
              String tmpDir = System.getProperty("java.io.tmpdir", ".");
              tmpDirFile = new File(tmpDir);
          }
          File result;
          do {
              result = new File(tmpDirFile, prefix + tempFileRandom.nextInt() + suffix);
          } while (!result.createNewFile());
          return result;
      }
docs: Creates an empty temporary file in the given directory using the given
  prefix and suffix as part of the file name. If {@code suffix} is null, {@code .tmp} is used.
  
  <p>Note that this method does <i>not</i> call {@link #deleteOnExit}, but see the
  documentation for that method before you call it manually.
  
  @param prefix
  the prefix to the temp file name.
  @param suffix
  the suffix to the temp file name.
  @param directory
  the location to which the temp file is to be written, or
  {@code null} for the default location for temporary files,
  which is taken from the "java.io.tmpdir" system property. It
  may be necessary to set this property to an existing, writable
  directory for this method to work properly.
  @return the temporary file.
  @throws IllegalArgumentException
  if the length of {@code prefix} is less than 3.
  @throws IOException
  if an error occurs when writing the file.