Generates a new temporary file name that is guaranteed to be unique.

@param prefix the prefix for the file name to generate
@param extension the extension of the generated file name
@return a temporary File
@throws java.io.IOException if any.
517208
public File getTempFile(@NotNull final String prefix, @NotNull final String extension) throws IOException {
        final File dir = getTempDirectory();
        final String tempFileName = String.format("%s%s.%s", prefix, UUID.randomUUID().toString(), extension);
        final File tempFile = new File(dir, tempFileName);
        if (tempFile.exists()) {
            return getTempFile(prefix, extension);
        }
        return tempFile;
    }
653120
public static String createEndSuffixFileName(String fileName, String endSuffix) {
        int    index       = fileName.lastIndexOf(".");
        String preFileName = fileName.substring(0, index);
        String suffix      = fileName.substring(index);
        return preFileName + endSuffix + suffix;
    }
331167
@Override
    public void setTemporaryQueueNamePrefix(final String prefix)
                    throws JMSException {
         
          temporaryQueueNamePrefix = prefix;
         // defect 99056
        _properties.put(JmsraConstants.TEMP_QUEUE_NAME_PREFIX, prefix);

        if ((prefix != null) && (prefix.length() > 12)) {

            final JMSException exception = new JMSException(NLS
                            .getFormattedMessage(("DESTINATION_PREFIX_LONG_CWSJR1025"),
                                                 new Object[] { prefix }, null));
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
                SibTr.exception(this, TRACE, exception);
            }
            throw exception;
        }

    }
394696
public static function getNewFileName($fileName, $prefix, $suffix)
    {
        $effect = $fileName;

        if (!empty($fileName) && (!empty($prefix) || !empty($suffix))) {
            $name = self::getFileNameWithoutExtension($fileName);
            $extension = self::getFileExtension($fileName);

            $effect = sprintf('%s%s%s.%s', $prefix, $name, $suffix, $extension);
        }

        return $effect;
    }
1373207
public File createTempDir(String prefix, String suffix) {
    try {
      // Create a tempfile, and delete it.
      File file = File.createTempFile(prefix, suffix, baseDir);
      file.delete();

      // Create it as a directory.
      File dir = new File(file.getAbsolutePath());
      if (!dir.mkdirs()) {
        throw new WebDriverException("Cannot create profile directory at " + dir.getAbsolutePath());
      }

      // Create the directory and mark it writable.
      FileHandler.createDir(dir);

      temporaryFiles.add(dir);
      return dir;
    } catch (IOException e) {
      throw new WebDriverException(
          "Unable to create temporary file at " + baseDir.getAbsolutePath());
    }
  }
1277181
private static File getTempPath(String prefix, File parentDir) throws IOException {
        final int maxI = (int)Math.pow(10, NUM_DIGITS);
        String formatStr = "%s_%0"+NUM_DIGITS+"d";
        File path;
        int i;
        for (i=0; i<maxI; i++) {
            path = new File(parentDir, String.format(formatStr, prefix, i));
            if (!path.exists()) {
                return path;
            }
        }
        // If we ran out of short file names, just create a long one
        path = File.createTempFile(prefix, "", parentDir);
        if (!path.delete()) {
            throw new RuntimeException("Could not delete temp file as expected: " + path);
        }
        return path;
    }
168316
public static String temporaryFileName(long nonce, String path) {
    return path + String.format(TEMPORARY_SUFFIX_FORMAT, nonce);
  }
85841
@Override
    public void setTemporaryTopicNamePrefix(final String prefix)
                    throws JMSException {
        // defect 99056
        _properties.put(JmsraConstants.TEMP_TOPIC_NAME_PREFIX, prefix);
        if ((prefix != null) && (prefix.length() > 12)) {

            final JMSException exception = new JMSException(NLS
                            .getFormattedMessage(("DESTINATION_PREFIX_LONG_CWSJR1029"),
                                                 new Object[] { prefix }, null));
            if (TraceComponent.isAnyTracingEnabled() && TRACE.isEntryEnabled()) {
                SibTr.exception(this, TRACE, exception);
            }

            throw exception;
        }

    }
1357011
public static String getRandomFilename(final String prefix) {

		final StringBuilder stringBuilder = new StringBuilder(prefix);

		for (int i = 0; i < LENGTH; i++) {
			stringBuilder.append(ALPHABET[(int) Math.floor(Math.random() * (double) ALPHABET.length)]);
		}

		return stringBuilder.toString();
	}
1301045
public static File createTempFile(File file) {
        String[] prefixSuffix = getPrefixSuffix(file);
        try {
            File tempFile =
                    File.createTempFile(prefixSuffix[0], prefixSuffix[1]);
            tempFile.deleteOnExit();
            return tempFile;
        } catch (Exception e) {
            return JMExceptionManager.handleExceptionAndReturnNull(log, e,
                    "createTempFile", file);
        }
    }
700314
private void registerPrefix(String field, String prefix,
      IndexOutput outPrefix) throws IOException {
    if (!prefixReferenceIndex.containsKey(field)) {
      prefixReferenceIndex.put(field, new HashMap<String, Long>());
      prefixIdIndex.put(field, new HashMap<String, Integer>());
    }
    if (!prefixReferenceIndex.get(field).containsKey(prefix)) {
      int id = 1 + prefixReferenceIndex.get(field).size();
      prefixReferenceIndex.get(field).put(prefix, outPrefix.getFilePointer());
      prefixIdIndex.get(field).put(prefix, id);
      outPrefix.writeString(prefix);
    }
  }
530756
public static function createTempPath($prefix = 'php-')
    {
        $temp = tempnam(sys_get_temp_dir(), $prefix);

        if (false === $temp) {
            // @codeCoverageIgnoreStart
            throw new FileException(
                'A new temporary file could not be created.'
            );
        }
        // @codeCoverageIgnoreEnd

        return $temp;
    }
888345
File writeTempCacheFile(InputStream stream, FileExtension extension) throws IOException {
    String fileName = filenameForUrl(url, extension, true);
    File file = new File(appContext.getCacheDir(), fileName);
    try {
      OutputStream output = new FileOutputStream(file);
      //noinspection TryFinallyCanBeTryWithResources
      try {
        byte[] buffer = new byte[1024];
        int read;

        while ((read = stream.read(buffer)) != -1) {
          output.write(buffer, 0, read);
        }

        output.flush();
      } finally {
        output.close();
      }
    } finally {
      stream.close();
    }
    return file;
  }
1305586
public void setPrefix(String prefix) {
		this.prefix = prefix;
		if (this.prefix != null && this.prefix.isEmpty())
			this.prefix = null;
	}
1298029
public static String getFileNameWithoutExtension(File file) {

		String name = file.getName();

		int extensionIndex = name.lastIndexOf(".");
		if (extensionIndex > -1) {
			name = name.substring(0, extensionIndex);
		}

		return name;
	}
10049
public static String getRandomFilename(final String prefix) {
		final Random rnd = new Random();
		final StringBuilder stringBuilder = new StringBuilder(prefix);

		for (int i = 0; i < RANDOM_FILE_NAME_LENGTH; i++) {
			stringBuilder.append(ALPHABET[rnd.nextInt(ALPHABET.length)]);
		}

		return stringBuilder.toString();
	}
483903
public static String uniquePath(String name, String ext) throws IOException
    {
        File file = File.createTempFile(name, ext);
        String path = file.getAbsolutePath();
        file.delete();

        return path;
    }