Pul kit
Pul kit

Reputation: 55

Alternative for File.createTempFile?

I don't want the extra number after file name when it is created using createTempFile. But I believe it is not possible to remove them. (How to change default name in createTempFile?).

In my case file name is very important. I cannot use new File() as it will create a file in local every-time.

Can someone suggest alternatives?

Upvotes: 0

Views: 587

Answers (1)

Jesper
Jesper

Reputation: 206816

You can create a temporary directory, which will be created in the directory that according to your operating system is the right place to create temporary directories, using Files.createTempDirectory(...).

In the directory that you created that way, you can create any file you like, using any filename you like.

Upvotes: 2

Related Questions