Dea5
Dea5

Reputation: 131

Is there a "Standard" path where you can create a "working folder"?

I'm writing a Java program that has to create a folder on the disk, store some file in it, and when the program is terminated, the folder is deleted:

The problem is that, when my program is opened on a random pc, how should it know where to store files?

I saw a lot of installers that already suggest you a path (like "Program Files", "Roaming" etc), how can I make my program know these paths? Thanks.

Upvotes: 1

Views: 35

Answers (1)

Timothy Truckle
Timothy Truckle

Reputation: 15622

The standard path is

System.getProperty("java.io.tmpdir");

See: https://docs.oracle.com/javase/7/docs/api/java/lang/System.html#getProperties()

you might use it together with

File.createTempFile();

as suggested in this answer: https://stackoverflow.com/a/617438/7023245

Upvotes: 3

Related Questions